diff --git a/docs/reference/mapping/types/geo-point.asciidoc b/docs/reference/mapping/types/geo-point.asciidoc index 2dd90a6ae61a8..f109deb0ab382 100644 --- a/docs/reference/mapping/types/geo-point.asciidoc +++ b/docs/reference/mapping/types/geo-point.asciidoc @@ -8,7 +8,7 @@ Fields of type `geo_point` accept latitude-longitude pairs, which can be used: * to find geo-points within a <>, within a certain <> of a central point, - or within a <>. + or within a <> or within a <>. * to aggregate documents <> or by <> from a central point. * to integrate distance into a document's <>. diff --git a/docs/reference/query-dsl/geo-shape-query.asciidoc b/docs/reference/query-dsl/geo-shape-query.asciidoc index 966267d4e3537..40cbe9b447f4e 100644 --- a/docs/reference/query-dsl/geo-shape-query.asciidoc +++ b/docs/reference/query-dsl/geo-shape-query.asciidoc @@ -23,7 +23,7 @@ examples. Similar to the `geo_shape` type, the `geo_shape` query uses http://www.geojson.org[GeoJSON] to represent shapes. -Given the following index: +Given the following index with locations as `geo_shape` fields: [source,console] -------------------------------------------------- @@ -77,6 +77,89 @@ GET /example/_search } -------------------------------------------------- +The above query can, similarly, be queried on `geo_point` fields. + +[source,console] +-------------------------------------------------- +PUT /example +{ + "mappings": { + "properties": { + "location": { + "type": "geo_point" + } + } + } +} + +POST /example/_doc?refresh +{ + "name": "Wind & Wetter, Berlin, Germany", + "location": [13.400544, 52.530286] +} +-------------------------------------------------- +// TESTSETUP + +Using the same query, the documents with matching `geo_point` fields are returned + +[source,console] +-------------------------------------------------- +GET /example/_search +{ + "query":{ + "bool": { + "must": { + "match_all": {} + }, + "filter": { + "geo_shape": { + "location": { + "shape": { + "type": "envelope", + "coordinates" : [[13.0, 53.0], [14.0, 52.0]] + }, + "relation": "within" + } + } + } + } + } +} +-------------------------------------------------- + +[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", + "_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 The Query also supports using a shape which has already been indexed in