Spatial queries with polygons require JTS

JTS (Java Topology Suite) is required to index polygon and multi-polygon shapes and perform queries using 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.

Geospatial data is stored in the database in WKT (Well Known Text) format. To support Polygons and MultiPolygons fields, set the field type in the table index schema to solr.SpatialRecursivePrefixTreeFieldType. This type supports polygons and multipolygons (multivalued spatial data).

Spatial field type with JTS enabled

For optimal indexing of multipolygon shapes, you must set useJtsMulti="false".

Geospatial data is stored in the database in WKT (Well Known Text) format. To support Polygons and MultiPolygons fields, set the field type in the table index schema to solr.SpatialRecursivePrefixTreeFieldType.

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"/>

SpatialRecursivePrefixTreeFieldType supports multiValued spatial data. Most states are describable as Polygons, but others such as Hawaii and Alaska are MultiPolygons.

Advanced spatial queries using spatial predicates

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 https://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: /usr/share/dse/solr/lib

  • Tarball installations: INSTALL_DIRECTORY/resources/solr/lib

DSE Search supports the following spatial predicates:

Intersects

Matches if the indexed value overlaps the search criteria.

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

Matches if the indexed value completely encapsulates the search criteria.

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

Matches if the index value does not overlap or touch the search criteria.

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

Matches if the indexed value completely contains the search criteria.

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?

© Copyright IBM Corporation 2026 | Privacy policy | Terms of use |  Manage Privacy Choices

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: Contact IBM