| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 | [[query-dsl-geo-shape-query]]=== GeoShape QueryFilter documents indexed using the `geo_shape` type.Requires the <<geo-shape,`geo_shape` Mapping>>.The `geo_shape` query uses the same grid square representation as thegeo_shape mapping to find documents that have a shape that intersectswith the query shape. It will also use the same PrefixTree configurationas defined for the field mapping.The query supports two ways of defining the query shape, either byproviding a whole shape definition, or by referencing the name of a shapepre-indexed in another index. Both formats are defined below withexamples.==== Inline Shape DefinitionSimilar to the `geo_shape` type, the `geo_shape` Filter useshttp://www.geojson.org[GeoJSON] to represent shapes.Given a document that looks like this:[source,js]--------------------------------------------------{    "name": "Wind & Wetter, Berlin, Germany",    "location": {        "type": "Point",        "coordinates": [13.400544, 52.530286]    }}--------------------------------------------------The following query will find the point using the Elasticsearch's`envelope` GeoJSON extension:[source,js]--------------------------------------------------{    "query":{        "filtered": {            "query": {                "match_all": {}            },            "filter": {                "geo_shape": {                    "location": {                        "shape": {                            "type": "envelope",                            "coordinates" : [[13.0, 53.0], [14.0, 52.0]]                        }                    }                }            }        }    }}--------------------------------------------------==== Pre-Indexed ShapeThe Filter also supports using a shape which has already been indexed inanother index and/or index type. This is particularly useful for whenyou have a pre-defined list of shapes which are useful to yourapplication and you want to reference this using a logical name (forexample 'New Zealand') rather than having to provide their coordinateseach time. In this situation it is only necessary to provide:* `id` - The ID of the document that containing the pre-indexed shape.* `index` - Name of the index where the pre-indexed shape is. Defaultsto 'shapes'.* `type` - Index type where the pre-indexed shape is.* `path` - The field specified as path containing the pre-indexed shape.Defaults to 'shape'.The following is an example of using the Filter with a pre-indexedshape:[source,js]--------------------------------------------------{    "filtered": {        "query": {            "match_all": {}        },        "filter": {            "geo_shape": {                "location": {                    "indexed_shape": {                        "id": "DEU",                        "type": "countries",                        "index": "shapes",                        "path": "location"                    }                }            }        }    }}--------------------------------------------------
 |