When you are working with geo locations, one of the common tasks is to filter results based on its distance from a location. The geo_distance
filter is used to achieve this goal.
You need a working ElasticSearch cluster and the data populated with the geo populate script.
Searching documents in which pin.location
is 200km
distant from the lat
value 40
and the lon
value 70
, is done using a similar query as follows:
curl -XGET 'http://127.0.0.1:9200/test-mindex/_search -d '{ "query": { "filtered": { "filter": { "geo_distance": { "pin.location": { "lat": 40, "lon": 70 }, "distance": "200km", "optimize_bbox": "memory" } }, "query": { "match_all": {} } } } }'