June 2017
Beginner to intermediate
404 pages
8h 22m
English
Geo Distance query is used to find the documents that are located within a certain distance from a given location. Let's query for all the stores within 1 mile of the user location. For this example, I'm assuming the user location as follows:
"lat": "37.348929", "lon": "-121.888536"
In the following Google Maps screenshot, the red pin represents the current user location, and the blue circle represents the 1-mile radius from the user location:

The query would look like the following:
POST chapter7/store/_search { "query": { "geo_distance": { "distance": "1mi", "location": { "lat": "37.348929", "lon": "-121.888536" } } } } ...Read now
Unlock full access