Executing the date histogram aggregation
The previous recipe works mainly on numeric fields; ElasticSearch provides a custom date histogram aggregation to operate on date/date-time values. This aggregation is required because date values need more customization to solve problems such as time zone conversion and special time intervals.
Getting ready
You need a working ElasticSearch cluster and an index populated with the script (chapter_06/executing_date_histogram_aggregations.sh
) available at https://github.com/aparo/elasticsearch-cookbook-second-edition.
How to do it...
We need two different date/time aggregations that are:
- An annual aggregation
- A quarter aggregation, but with time zone +1:00
To execute date histogram aggregations, we will perform the ...
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.