I want to get return bucket even though the count is 0. How to get daily histogram buckets with 0 count??
My aggregation query is below. I want to every histogram buckets from last Sunday to Saturday.
{
"size": 0,
"aggs": {
"range": {
"date_range": {
"time_zone": "Asia/Tokyo",
"field": "@timestamp",
"ranges": [
{
"from": "now-11d/d",
"to": "now-4d/d"
}
]
},
"aggs": {
"date": {
"date_histogram": {
"field": "@timestamp",
"calendar_interval": "day",
"time_zone": "Asia/Tokyo"
}
}
}
}
}
}
But I can't get Sunday bucket(31st March) with 0 count.
"aggregations": {
"range": {
"buckets": [
{
"key": "2024-03-31T00:00:00.000+09:00-2024-04-07T00:00:00.000+09:00",
"from": 1711810800000,
"from_as_string": "2024-03-31T00:00:00.000+09:00",
"to": 1712415600000,
"to_as_string": "2024-04-07T00:00:00.000+09:00",
"doc_count": 228,
"date": {
"buckets": [
{
"key_as_string": "2024-04-01T00:00:00.000+09:00",
"key": 1711897200000,
"doc_count": 2
},
{
"key_as_string": "2024-04-02T00:00:00.000+09:00",
"key": 1711983600000,
"doc_count": 0
},
{
"key_as_string": "2024-04-03T00:00:00.000+09:00",
"key": 1712070000000,
"doc_count": 212
},
{
"key_as_string": "2024-04-04T00:00:00.000+09:00",
"key": 1712156400000,
"doc_count": 6
},
{
"key_as_string": "2024-04-05T00:00:00.000+09:00",
"key": 1712242800000,
"doc_count": 8
}
]
}
}
]
}
}