Using the geo_distance_range query
It's a common scenario to find documents distant from a single point (epicenter) in a range.
One example, is when you have indexed a list of points of interest (shops, monuments, airports, train stations, and so on) and you need to know how many of them are in the range between 100 and 200 kilometers.
Getting ready
You need an up-and-running Elasticsearch installation as we described in the Downloading and installing Elasticsearch recipe in Chapter 2, Downloading and Setup.
To execute curl
via the command line, you need to install curl
for your operating system.
To correct execute the following commands, you need an index populated with the chapter_07/populate_geo.sh
geoscript available in the online code.
How to do it...
To execute a geo_distance_range
query, we will perform the following steps:
Searching documents in which pin.location is
100km
to200km
away from Âlat
 Â40
 andlon
, is done with a similar query:curl -XGET 'http://127.0.0.1:9200/test-mindex...