mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-04-25 23:57:20 -04:00
Closes #16964 Squashed commit of the following: commit a23f9d2d29220991aa498214530753d7a5a148c6 Merge:eec9c4e
0b0a251
Author: Robert Muir <rmuir@apache.org> Date: Mon Mar 7 04:12:02 2016 -0500 Merge branch 'master' into lucene6 commiteec9c4e5cd
Merge:bc67205
675d940
Author: Robert Muir <rmuir@apache.org> Date: Fri Mar 4 13:45:00 2016 -0500 Merge branch 'master' into lucene6 commitbc67205bdf
Author: Robert Muir <rmuir@apache.org> Date: Fri Mar 4 09:56:31 2016 -0500 fix test bug commita60723b007
Author: Simon Willnauer <simonw@apache.org> Date: Fri Mar 4 15:35:35 2016 +0100 Fix SimpleValidateQueryIT to put braces around boosted terms commitae3a49d7ba
Author: Simon Willnauer <simonw@apache.org> Date: Fri Mar 4 15:27:25 2016 +0100 fix multimatchquery commitae23fdb88a
Author: Simon Willnauer <simonw@apache.org> Date: Fri Mar 4 15:20:49 2016 +0100 Rewrite DecayFunctionScoreIT to be independent of the similarity used This test relied a lot on the term scoring and compared scores that are dependent on the similarity. This commit changes the base query to be a predictable constant score query. commit366c2d518c
Author: Simon Willnauer <simonw@apache.org> Date: Fri Mar 4 14:06:14 2016 +0100 Fix scoring in tests due to changes to idf calculation. Lucene 6 uses a different default similarity as well as a different way to calculate IDF. In contrast to older version lucene 6 uses docCount per field to calculate the IDF not the # of docs in the index to overcome the sparse field cases. commitdac99fd64a
Author: Robert Muir <rmuir@apache.org> Date: Fri Mar 4 08:21:57 2016 -0500 don't hardcoded expected termquery score commit6e9f340ba4
Author: Robert Muir <rmuir@apache.org> Date: Fri Mar 4 08:04:45 2016 -0500 suppress deprecation warning until migrated to points commit3ac8908424
Author: Robert Muir <rmuir@apache.org> Date: Fri Mar 4 07:21:43 2016 -0500 Remove invalid test: all commits have IDs, and its illegal to do this. commitc129762881
Author: Robert Muir <rmuir@apache.org> Date: Fri Mar 4 07:06:14 2016 -0500 don't test with unsupported back compat commit18bbfe7612
Author: Robert Muir <rmuir@apache.org> Date: Fri Mar 4 07:02:18 2016 -0500 remove now invalid lucene 4 backcompat test commit7e730e5728
Author: Robert Muir <rmuir@apache.org> Date: Fri Mar 4 06:58:52 2016 -0500 remove now invalid lucene 4 backwards test commit244d2ab686
Author: Robert Muir <rmuir@apache.org> Date: Fri Mar 4 06:47:23 2016 -0500 use 6.0 codec commit5f64d4a431
Author: Robert Muir <rmuir@apache.org> Date: Fri Mar 4 06:43:08 2016 -0500 compile, javadocs, forbidden-apis, etc commit1f273cd62a
Merge:cd33921
29e3443
Author: Simon Willnauer <simonw@apache.org> Date: Fri Mar 4 10:45:29 2016 +0100 Merge branch 'master' into lucene6 commitcd33921ac7
Author: Robert Muir <rmuir@apache.org> Date: Thu Mar 3 23:58:37 2016 -0500 fix hunspell dictionary loading commitc7fdbd837b
Merge:4d4190f
d8948ba Author: Robert Muir <rmuir@apache.org> Date: Thu Mar 3 23:41:53 2016 -0500 Merge branch 'master' into lucene6 commit4d4190fd82
Author: Robert Muir <rmuir@apache.org> Date: Thu Mar 3 23:39:14 2016 -0500 remove nocommit commit77ca69e288
Author: Robert Muir <rmuir@apache.org> Date: Thu Mar 3 23:38:24 2016 -0500 clean up numericutils vs legacynumericutils commita466d696fb
Author: Robert Muir <rmuir@apache.org> Date: Thu Mar 3 23:32:43 2016 -0500 upgrade spatial4j commit5412c747a8
Author: Robert Muir <rmuir@apache.org> Date: Thu Mar 3 23:19:28 2016 -0500 move to 6.0.0-snapshot-8eada27 commitb32bfe9246
Author: Adrien Grand <jpountz@gmail.com> Date: Thu Mar 3 11:30:09 2016 +0100 Fix some test compile errors. commit6ccde35e98
Author: Adrien Grand <jpountz@gmail.com> Date: Thu Mar 3 11:25:51 2016 +0100 Current Lucene version is 6.0.0. commitf62e1015d9
Author: Adrien Grand <jpountz@gmail.com> Date: Thu Mar 3 11:20:48 2016 +0100 Fix compile errors in NGramTokenFilterFactory. commit6837c6eabf
Author: Adrien Grand <jpountz@gmail.com> Date: Thu Mar 3 10:50:59 2016 +0100 Fix the edge ngram tokenizer/filter. commitccd7f070de
Author: Adrien Grand <jpountz@gmail.com> Date: Thu Mar 3 10:42:44 2016 +0100 The missing value is now accessible through a getter. commitbd3b77f9b2
Author: Adrien Grand <jpountz@gmail.com> Date: Thu Mar 3 10:41:51 2016 +0100 Remove IndexCacheableQuery. commit05f3091c34
Author: Adrien Grand <jpountz@gmail.com> Date: Thu Mar 3 10:39:43 2016 +0100 Fix compilation of function_score queries. commit81cda79a24
Author: Adrien Grand <jpountz@gmail.com> Date: Thu Mar 3 10:35:02 2016 +0100 Fix compile errors in BlendedTermQuery. commit70994ce8dd
Author: Robert Muir <rmuir@apache.org> Date: Wed Mar 2 23:33:03 2016 -0500 add bug ID commit29d4f1a71f
Author: Robert Muir <rmuir@apache.org> Date: Wed Mar 2 21:02:32 2016 -0500 easy .store changes commit5e1a1e6fd6
Author: Robert Muir <rmuir@apache.org> Date: Wed Mar 2 20:47:24 2016 -0500 cleanups mostly around boosting commit333a669ec6
Author: Robert Muir <rmuir@apache.org> Date: Wed Mar 2 20:27:56 2016 -0500 more simple fixes commitbd5cd98a1e
Author: Robert Muir <rmuir@apache.org> Date: Wed Mar 2 19:49:38 2016 -0500 more easy fixes and removal of ancient cruft commita68f419ee4
Author: Robert Muir <rmuir@apache.org> Date: Wed Mar 2 19:35:02 2016 -0500 cutover numerics commit4ca5dc1fa4
Author: Robert Muir <rmuir@apache.org> Date: Wed Mar 2 18:34:18 2016 -0500 fix some constants commit88710a1781
Author: Robert Muir <rmuir@apache.org> Date: Wed Mar 2 18:14:25 2016 -0500 Add spatial-extras jar as a core dependency commitc8cd672658
Author: Robert Muir <rmuir@apache.org> Date: Wed Mar 2 18:03:33 2016 -0500 update to lucene 6 jars
73 lines
2.7 KiB
Text
73 lines
2.7 KiB
Text
[[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.6</version> <1>
|
|
</dependency>
|
|
|
|
<dependency>
|
|
<groupId>com.vividsolutions</groupId>
|
|
<artifactId>jts</artifactId>
|
|
<version>1.13</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%22com.vividsolutions%22%20AND%20a%3A%22jts%22[Maven Central]
|
|
|
|
[source,java]
|
|
--------------------------------------------------
|
|
// Import ShapeRelation and ShapeBuilder
|
|
import org.elasticsearch.common.geo.ShapeRelation;
|
|
import org.elasticsearch.common.geo.builders.ShapeBuilder;
|
|
--------------------------------------------------
|
|
|
|
[source,java]
|
|
--------------------------------------------------
|
|
GeoShapeQueryBuilder qb = geoShapeQuery(
|
|
"pin.location", <1>
|
|
ShapeBuilder.newMultiPoint() <2>
|
|
.point(0, 0)
|
|
.point(0, 10)
|
|
.point(10, 10)
|
|
.point(10, 0)
|
|
.point(0, 0));
|
|
qb.relation(ShapeRelation.WITHIN); <3>
|
|
|
|
--------------------------------------------------
|
|
<1> field
|
|
<2> shape
|
|
<3> relation can be `ShapeRelation.WITHIN`, `ShapeRelation.INTERSECTS` or `ShapeRelation.DISJOINT`
|
|
|
|
[source,java]
|
|
--------------------------------------------------
|
|
// Using pre-indexed shapes
|
|
GeoShapeQueryBuilder qb = geoShapeQuery(
|
|
"pin.location", <1>
|
|
"DEU", <2>
|
|
"countries"); <3>
|
|
qb.relation(ShapeRelation.WITHIN)) <4>
|
|
.indexedShapeIndex("shapes") <5>
|
|
.indexedShapePath("location"); <6>
|
|
--------------------------------------------------
|
|
<1> field
|
|
<2> The ID of the document that containing the pre-indexed shape.
|
|
<3> Index type where the pre-indexed shape is.
|
|
<4> relation
|
|
<5> Name of the index where the pre-indexed shape is. Defaults to 'shapes'.
|
|
<6> The field specified as path containing the pre-indexed shape. Defaults to 'shape'.
|