Executing histogram aggregations
Elasticsearch numerical values can be used to process histogram data. The histogram representation is a very powerful way to show data to end users, mainly via bar charts.
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 operative system.
To correctly execute the following command, you need an index populated with the chapter_08/populate_aggregations.sh
script available in the online code.
How to do it...
For executing histogram aggregations, we will perform the following steps:
Using the items populated with the script, we want calculate the following aggregations:
age with an interval of 5 years
price with an interval of 10$
date with an interval of 6 months
The query will be as follows:
curl -XGET 'http://127.0.0.1:9200/test-index/test-type/_search? ...