Expected: When performing a range query, I expect the histogram buckets to show all docs.
Actual: Only the bucket that matches the range query is returned.
When performing this "match_all" query:
GET /article/_search
{
"query": {
"match_all": {}
},
"aggs": {
"archives": {
"date_histogram": {
"min_doc_count": 0,
"field": "created_at",
"interval": "month"
}
}
}
}
I get two "archives" buckets:
"aggregations": {
"archives": {
"buckets": [
{
"key_as_string": "2018-04-01T00:00:00.000Z",
"key": 1522540800000,
"doc_count": 1
},
{
"key_as_string": "2018-05-01T00:00:00.000Z",
"key": 1525132800000,
"doc_count": 4
}
]
}
...
When performing this range query:
GET /article/_search
{
"query": {
"range": {
"created_at": {
"gte": "2018-05-01||/M",
"lt": "2018-05-01||+1M/M"
}
}
},
"aggs": {
"archives": {
"date_histogram": {
"min_doc_count": 0,
"field": "created_at",
"interval": "month"
}
}
}
}
I expect the first bucket to be present with "doc_count" = 0, but instead I only get the matching bucket in the response:
"aggregations": {
"archives": {
"buckets": [
{
"key_as_string": "2018-05-01T00:00:00.000Z",
"key": 1525132800000,
"doc_count": 4
}
]
},
Can someone please point me in the right direction.