Executing the histogram aggregation
ElasticSearch numerical values can be used to process histogram data. The histogram representation is a very powerful way to show data to end users.
Getting ready
You need a working ElasticSearch cluster and an index populated with the script (chapter_06/executing_histogram_aggregations.sh
) available at https://github.com/aparo/elasticsearch-cookbook-second-edition.
How to do it...
Using the items populated with the script, we want to calculate aggregations on:
- Age with an interval of 5 years
- Price with an interval of 10$
- Date with an interval of 6 months
To execute histogram aggregations, we will perform the steps given as follows:
- The query will be as follows:
curl -XGET 'http://127.0.0.1:9200/test-index/test-type/_search?pretty=true&size=0' ...
Get ElasticSearch Cookbook - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.