OpenSearch/docs/java-api/query-dsl/geo-shape-query.asciidoc

57 lines
2.2 KiB
Plaintext

[[java-query-dsl-geo-shape-query]]
==== GeoShape Query
See {ref}/query-dsl-geo-shape-query.html[Geo Shape Query]
Note: the `geo_shape` type uses `Spatial4J` and `JTS`, both of which are
optional dependencies. Consequently you must add `Spatial4J` and `JTS`
to your classpath in order to use this type:
[source,xml]
-----------------------------------------------
<dependency>
<groupId>org.locationtech.spatial4j</groupId>
<artifactId>spatial4j</artifactId>
<version>0.7</version> <1>
</dependency>
<dependency>
<groupId>org.locationtech.jts</groupId>
<artifactId>jts-core</artifactId>
<version>1.15.0</version> <2>
<exclusions>
<exclusion>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
</exclusion>
</exclusions>
</dependency>
-----------------------------------------------
<1> check for updates in http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.locationtech.spatial4j%22%20AND%20a%3A%22spatial4j%22[Maven Central]
<2> check for updates in http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.locationtech.jts%22%20AND%20a%3A%22jts-core%22[Maven Central]
[source,java]
--------------------------------------------------
// Import ShapeRelation and ShapeBuilder
import org.elasticsearch.common.geo.ShapeRelation;
import org.elasticsearch.common.geo.builders.ShapeBuilder;
--------------------------------------------------
["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{query-dsl-test}[geo_shape]
--------------------------------------------------
<1> field
<2> shape
<3> relation can be `ShapeRelation.CONTAINS`, `ShapeRelation.WITHIN`, `ShapeRelation.INTERSECTS` or `ShapeRelation.DISJOINT`
["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{query-dsl-test}[indexed_geo_shape]
--------------------------------------------------
<1> field
<2> The ID of the document that containing the pre-indexed shape.
<3> relation
<4> Name of the index where the pre-indexed shape is. Defaults to 'shapes'.
<5> The field specified as path containing the pre-indexed shape. Defaults to 'shape'.