Using the geo_bounding_box query
One of most common operations in geolocalization is searching for a box (square).
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 correctly 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 geobounding box query, we will perform the following steps:
A search to filter documents related to a bounding box
40.03
,72.0
and40.717
,70.99
can be done with a similar query:curl -XPOST http://127.0.0.1:9200/test-mindex/_search?pretty -d '{ "query": { "geo_bounding_box": { "pin.location": { "bottom_right": { ...