Challenge - 5 Problems
Date Histogram Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of a basic date histogram aggregation
What is the output of this Elasticsearch aggregation query on an index with documents dated from 2023-01-01 to 2023-01-05, one document per day?
Elasticsearch
{
"aggs": {
"sales_over_time": {
"date_histogram": {
"field": "date",
"calendar_interval": "day"
}
}
}
}Attempts:
2 left
💡 Hint
Each day has exactly one document, so each day bucket should have doc_count 1.
✗ Incorrect
The date_histogram with calendar_interval day groups documents by each day. Since there is one document per day from Jan 1 to Jan 5, each bucket has doc_count 1.
❓ Predict Output
intermediate2:00remaining
Effect of missing min_doc_count in date histogram
Given documents on 2023-01-01 and 2023-01-03 only, what buckets will the following date_histogram aggregation return?
Elasticsearch
{
"aggs": {
"sales_over_time": {
"date_histogram": {
"field": "date",
"calendar_interval": "day"
}
}
}
}Attempts:
2 left
💡 Hint
By default, buckets with zero documents are not included.
✗ Incorrect
Without min_doc_count set to 0, buckets with zero documents are omitted. So only days with documents appear.
❓ Predict Output
advanced2:00remaining
Output of date histogram with offset
What is the first bucket key_as_string returned by this aggregation on documents dated 2023-01-01 to 2023-01-05?
Elasticsearch
{
"aggs": {
"sales_over_time": {
"date_histogram": {
"field": "date",
"calendar_interval": "day",
"offset": "+12h"
}
}
}
}Attempts:
2 left
💡 Hint
Offset shifts the bucket boundaries by 12 hours earlier.
✗ Incorrect
The offset +12h shifts the bucket start times 12 hours earlier, so the first bucket starts at 2022-12-31T12:00:00Z.
❓ Predict Output
advanced2:00remaining
Result of date histogram with extended_bounds
Given documents only on 2023-01-01 and 2023-01-03, what buckets will this aggregation return?
Elasticsearch
{
"aggs": {
"sales_over_time": {
"date_histogram": {
"field": "date",
"calendar_interval": "day",
"min_doc_count": 0,
"extended_bounds": {
"min": "2023-01-01",
"max": "2023-01-04"
}
}
}
}
}Attempts:
2 left
💡 Hint
extended_bounds forces buckets for all days in the range, even if no documents exist.
✗ Incorrect
With min_doc_count 0 and extended_bounds from 2023-01-01 to 2023-01-04, buckets for all days in range appear, zero count if no docs.
🧠 Conceptual
expert2:00remaining
Understanding time zone effect on date histogram buckets
If you run a date_histogram aggregation with calendar_interval day on a field with UTC timestamps, but set "time_zone": "+02:00", what effect does this have on the bucket boundaries?
Attempts:
2 left
💡 Hint
Time zone shifts bucket boundaries relative to UTC time.
✗ Incorrect
Setting time_zone +02:00 shifts bucket boundaries 2 hours earlier in UTC, so buckets start at 22:00 UTC previous day, covering 24 hours.