The previous recipe, Using the geo_bounding_box filter shows how to filter on a square section, which is the most common case. ElasticSearch provides a way to filter the user defined polygonal shapes via the geo_polygon
filter.
You need a working ElasticSearch cluster and the data populated with the geo populate script.
Searching documents in which pin.location
is part of a triangle (a shape made up of three GeoPoints), is done by using a similar query as follows:
curl -XGET http://127.0.0.1:9200/test-mindex/_search -d '{ "query": { "filtered": { "filter": { "geo_bounding_box": { "pin.location": { "points": [ { "lat": 50, "lon": -30 }, { "lat": 30, ...