Using the geo_shape query
The Using the geo_bounding_box query recipe shows how to filter the square section, which is the most common case; Elasticsearch provides a way to filter user-defined shapes using the geo_shape
query.
The common scenario when using this kind of query is searching for complex shapes such as countries, regions, or districts.
Getting ready
You need an up-and-running Elasticsearch installation, as we described in the Downloading and installing Elasticsearch recipe in Chapter 1, Getting Started.
To execute these commands, I suggest using the Kibana console, as this provides code completion, code formatting, and better character escaping for Elasticsearch.
To correctly execute the following commands, you will need an index populated with the ch04/populate_kibana.txt
commands, which are available in the online code.
The index that's used in this section is mygeo-index
.
How to do it...
To execute...