Executing a range aggregation
The previous recipe describes an aggregation type that can be very useful if buckets must be computed on fixed terms or on a limited number of items. Otherwise, it’s often required to return the buckets aggregated in ranges; the range aggregations meet this requirement. Commons scenarios are as follows:
- Price range (used in shops)
- Size range
- Alphabetical range
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 the commands, any HTTP client can be used, such as cURL (https://curl.haxx.se/), Postman (https://www.getpostman.com/), or similar. Using Kibana Console is recommended, as it provides code completion and better character escaping for Elasticsearch.
To correctly execute the following commands, you will need an index populated with the ch07/populate_aggregation.sh
commands available...