Update geo_point docs for geo_shape queries (#57487)
This commit highlights the ability for geo_point fields to be used in geo_shape queries. It also adds an explicit geo_point example in the geo_shape query documentation Closes #56927.
This commit is contained in:
parent
97c06816a4
commit
f360020048
|
@ -8,7 +8,7 @@ Fields of type `geo_point` accept latitude-longitude pairs, which can be used:
|
||||||
|
|
||||||
* to find geo-points within a <<query-dsl-geo-bounding-box-query,bounding box>>,
|
* to find geo-points within a <<query-dsl-geo-bounding-box-query,bounding box>>,
|
||||||
within a certain <<query-dsl-geo-distance-query,distance>> of a central point,
|
within a certain <<query-dsl-geo-distance-query,distance>> of a central point,
|
||||||
or within a <<query-dsl-geo-polygon-query,polygon>>.
|
or within a <<query-dsl-geo-polygon-query,polygon>> or within a <<query-dsl-geo-shape-query,geo_shape query>>.
|
||||||
* to aggregate documents <<search-aggregations-bucket-geohashgrid-aggregation,geographically>>
|
* to aggregate documents <<search-aggregations-bucket-geohashgrid-aggregation,geographically>>
|
||||||
or by <<search-aggregations-bucket-geodistance-aggregation,distance>> from a central point.
|
or by <<search-aggregations-bucket-geodistance-aggregation,distance>> from a central point.
|
||||||
* to integrate distance into a document's <<query-dsl-function-score-query,relevance score>>.
|
* to integrate distance into a document's <<query-dsl-function-score-query,relevance score>>.
|
||||||
|
|
|
@ -23,7 +23,7 @@ examples.
|
||||||
Similar to the `geo_shape` type, the `geo_shape` query uses
|
Similar to the `geo_shape` type, the `geo_shape` query uses
|
||||||
http://www.geojson.org[GeoJSON] to represent shapes.
|
http://www.geojson.org[GeoJSON] to represent shapes.
|
||||||
|
|
||||||
Given the following index:
|
Given the following index with locations as `geo_shape` fields:
|
||||||
|
|
||||||
[source,console]
|
[source,console]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
@ -77,6 +77,90 @@ GET /example/_search
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
|
||||||
|
The above query can, similarly, be queried on `geo_point` fields.
|
||||||
|
|
||||||
|
[source,console]
|
||||||
|
--------------------------------------------------
|
||||||
|
PUT /example_points
|
||||||
|
{
|
||||||
|
"mappings": {
|
||||||
|
"properties": {
|
||||||
|
"location": {
|
||||||
|
"type": "geo_point"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PUT /example_points/_doc/1?refresh
|
||||||
|
{
|
||||||
|
"name": "Wind & Wetter, Berlin, Germany",
|
||||||
|
"location": [13.400544, 52.530286]
|
||||||
|
}
|
||||||
|
--------------------------------------------------
|
||||||
|
// TEST[continued]
|
||||||
|
|
||||||
|
Using the same query, the documents with matching `geo_point` fields are returned
|
||||||
|
|
||||||
|
[source,console]
|
||||||
|
--------------------------------------------------
|
||||||
|
GET /example_points/_search
|
||||||
|
{
|
||||||
|
"query":{
|
||||||
|
"bool": {
|
||||||
|
"must": {
|
||||||
|
"match_all": {}
|
||||||
|
},
|
||||||
|
"filter": {
|
||||||
|
"geo_shape": {
|
||||||
|
"location": {
|
||||||
|
"shape": {
|
||||||
|
"type": "envelope",
|
||||||
|
"coordinates" : [[13.0, 53.0], [14.0, 52.0]]
|
||||||
|
},
|
||||||
|
"relation": "intersects"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
--------------------------------------------------
|
||||||
|
// TEST[continued]
|
||||||
|
|
||||||
|
[source,console-result]
|
||||||
|
--------------------------------------------------
|
||||||
|
{
|
||||||
|
"took" : 17,
|
||||||
|
"timed_out" : false,
|
||||||
|
"_shards" : {
|
||||||
|
"total" : 1,
|
||||||
|
"successful" : 1,
|
||||||
|
"skipped" : 0,
|
||||||
|
"failed" : 0
|
||||||
|
},
|
||||||
|
"hits" : {
|
||||||
|
"total" : {
|
||||||
|
"value" : 1,
|
||||||
|
"relation" : "eq"
|
||||||
|
},
|
||||||
|
"max_score" : 1.0,
|
||||||
|
"hits" : [
|
||||||
|
{
|
||||||
|
"_index" : "example_points",
|
||||||
|
"_id" : "1",
|
||||||
|
"_score" : 1.0,
|
||||||
|
"_source" : {
|
||||||
|
"name": "Wind & Wetter, Berlin, Germany",
|
||||||
|
"location": [13.400544, 52.530286]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
--------------------------------------------------
|
||||||
|
// TESTRESPONSE[s/"took" : 17/"took" : $body.took/]
|
||||||
|
|
||||||
==== Pre-Indexed Shape
|
==== Pre-Indexed Shape
|
||||||
|
|
||||||
The Query also supports using a shape which has already been indexed in
|
The Query also supports using a shape which has already been indexed in
|
||||||
|
|
Loading…
Reference in New Issue