Spatial queries with polygons require JTS
JTS is required to index polygon/multipolygon andor perform queries that include polygon shapes.
JTS (Java Topology Suite) is required to index polygon/multipolygon and perform queries that include polygon shapes. Dynamic fields for spatial subfields use prefix naming conventions to enable map types to store geospatial data. DSE Search includes the Apache Solr™ Spatial4j library that adds advanced spatial types like polygons to search indexes.
Spatial field type with JTS enabled
useJtsMulti="false"
. For
example:<fieldType autoIndex="true" useJtsMulti="false"
class="solr.SpatialRecursivePrefixTreeFieldType" distErrPct="0.0125"
distanceUnits="kilometers" geo="true" name="WktField" spatialContextFactory="org.locationtech.
spatial4j.context.jts.JtsSpatialContextFactory"/>
Advanced spatial queries
Performing spatial queries that include polygon shapes requires installing the JTS (Java Topology Suite) library into the DataStax Enterprise Solr library directory. Download version 1.13 of the jts.jar file from http://central.maven.org/maven2/com/vividsolutions/jts/1.13/ and install in the Solr library path:
- Package installations: /usr/share/dse/solr/lib
- Tarball installations: installation_location/resources/solr/lib
Spatial predicates
- Intersects
- IsWithin
- IsDisjointTo
- Contains
Examples
fq=geo:"Intersects(-74.093 41.042 -69.347 44.558)"
fq=geo:"IsWithin(POLYGON((-10 30, -40 40, -10 -20, 40 20, 0 0, -10 30))) distErrPct=0"
fq=geo:"IsDisjointTo(POLYGON((-10 30, -40 40, -10 -20, 40 20, 0 0, -10 30))) distErrPct=0"
fq=geo:"Contains(POLYGON((-10 30, -40 40, -10 -20, 40 20, 0 0, -10 30))) distErrPct=0"