Executing date histogram aggregations
The previous recipe used mainly numeric fields; Elasticsearch provides special functionalities to compute the date histogram aggregation which operates on date
/datetime
values.
This aggregation is required because date values need more customization to solve problems such as timezone conversion and special time intervals.
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 date histogram aggregations, we will perform the following steps:
We need two different date/time aggregations that are as follows:
An annual aggregation
A quarter aggregation, but with time zone +1...