Spatial queries with polygons require JTS

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

For optimal indexing of multipolygon shapes, you must set 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:

The default Solr library path location depends on the type of installation:

  • Package installations and Installer-Services: /usr/share/dse/solr/lib

  • Tarball installations and Installer-No Services: <installation_location>/resources/solr/lib

Spatial predicates

DSE Search supports these spatial predicates:

  • Intersects

  • IsWithin

  • IsDisjointTo

  • Contains

Examples

Intersects

fq=geo:"Intersects(-74.093 41.042 -69.347 44.558)"

IsWithin

fq=geo:"IsWithin(POLYGON((-10 30, -40 40, -10 -20, 40 20, 0 0, -10 30))) distErrPct=0"

IsDisjointTo

fq=geo:"IsDisjointTo(POLYGON((-10 30, -40 40, -10 -20, 40 20, 0 0, -10 30))) distErrPct=0"

Contains

fq=geo:"Contains(POLYGON((-10 30, -40 40, -10 -20, 40 20, 0 0, -10 30))) distErrPct=0"

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2024 DataStax | Privacy policy | Terms of use

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: +1 (650) 389-6000, info@datastax.com