I am porting an application from Lucene to Solr which makes use of spatial4j 
for distance searches.  The Lucene version works correctly but I am having a 
problem getting the Solr version to work in the same way.

Lucene version:

SpatialContext geoSpatialCtx = SpatialContext.GEO;

       geoSpatialStrategy = new RecursivePrefixTreeStrategy(new 
GeohashPrefixTree(
                     geoSpatialCtx, GeohashPrefixTree.getMaxLevelsPossible()), 
DocumentFieldNames.LOCATION);


       Point point = geoSpatialCtx.makePoint(lon, lat);
       for (IndexableField field : 
geoSpatialStrategy.createIndexableFields(point)) {
              document.add(field);
       }

       //Store the field
       document.add(new StoredField(geoSpatialStrategy.getFieldName(), 
geoSpatialCtx.toString(point)));

Solr version:

       Point point = geoSpatialCtx.makePoint(lon, lat);
       for (IndexableField field : 
geoSpatialStrategy.createIndexableFields(point)) {
              try {
                     solrDocument.addField(field.name(), 
field.tokenStream(analyzer));
              } catch (IOException e) {
                     LOGGER.error("Failed to add geo field to Solr index", e);
              }
       }

       // Store the field
       solrDocument.addField(geoSpatialStrategy.getFieldName(), 
geoSpatialCtx.toString(point));

The server-side error is as follows:

Caused by: com.spatial4j.core.exception.InvalidShapeException: Unable to read: 
org.apache.lucene.spatial.prefix.PrefixTreeStrategy$CellTokenStr\
eam@0
        at 
com.spatial4j.core.io.ShapeReadWriter.readShape(ShapeReadWriter.java:48)
        at 
com.spatial4j.core.context.SpatialContext.readShape(SpatialContext.java:195)
        at 
org.apache.solr.schema.AbstractSpatialFieldType.parseShape(AbstractSpatialFieldType.java:142)

I've seen David Smiley's sample code, specifically the class, 
SpatialDemoUpdateProcessorFactory, but I can't say that I was able to benefit 
from it at all.

What I'm trying to do seems like it should be easy - just to index a point for 
distance searching - but I'm obviously missing something.

Any ideas?
Thanks,
Jim

The information contained in this email message, including any attachments, is 
intended solely for use by the individual or entity named above and may be 
confidential. If the reader of this message is not the intended recipient, you 
are hereby notified that you must not read, use, disclose, distribute or copy 
any part of this communication. If you have received this communication in 
error, please immediately notify me by email and destroy the original message, 
including any attachments. Thank you.

Reply via email to