Hi All,
I've been trying to get the brand new spatial search functionality
working with Solr 4 snapshot apache-solr-4.1-2012-09-24_05-10-26 and
also a trunk build from 22 Sep. I have added the jts and jts-io
libraries and defined a field as follows:
<fieldType name="geo" class="solr.SpatialRecursivePrefixTreeFieldType"
spatialContextFactory="com.spatial4j.core.context.jts.JtsSpatialContextFactory"
units="degrees" distErrPct="0.025" maxDistErr="0.000009" />
[...]
<dynamicField name="*_geo" type="geo" indexed="true" stored="true"
multiValued="true" />
There are no errors during Solr startup, and I can successfully index
and search rectangles, but I can't get the polygon search to work. E.g.
this search:
q=*:*&fq=location_geo:%22Intersects%28POLYGON%28%28-10%2030,%20-40%2040,%20-10%20-20,%2040%2020,%200%200,%20-10%2030%29%29%29%22
Results in the following error:
Unable to read: POLYGON((-10 30, -40 40, -10 -20, 40 20, 0 0, -10 30))
The call stack implies that JTS is not being used:
com.spatial4j.core.exception.InvalidShapeException: Unable to read:
POLYGON((-10 30, -40 40, -10 -20, 40 20, 0 0, -10 30))
at
com.spatial4j.core.io.ShapeReadWriter.readShape(ShapeReadWriter.java:48)
at
org.apache.lucene.spatial.query.SpatialArgsParser.parse(SpatialArgsParser.java:89)
at
org.apache.solr.schema.AbstractSpatialFieldType.getFieldQuery(AbstractSpatialFieldType.java:170)
at
org.apache.solr.search.SolrQueryParser.getFieldQuery(SolrQueryParser.java:171)
[...]
As far as I can see, ShapeReadWriter in spatial4j doesn't support
polygons, and JTS is needed for that. I've read
http://wiki.apache.org/solr/SolrAdaptersForLuceneSpatial4 (which is a
bit vague and partly outdated) and some of the JIRA issues too (e.g.
SOLR-3304, SOLR-2268, LUCENE-3795), but did not notice what I'm missing.
Any pointers or hints on what to do to make this work would be highly
appreciated. Thanks!
Regards,
Ere
--
Ere Maijala (Mr.)
The National Library of Finland