With the Date Histogram Aggregation is it possible to return a complete list of days, even if none of them have found results?
I am using a query to look for sales that occurred in a range of days, but in some cases there are no sales in the defined period, or just a sale at the end of the period, so only the days that have something appear.
localhost:9200/sales/_search?size=0`
{
"query": {
"range": {
"date": {
"from": "2020-01-01T00:00:00+0300",
"to": "2020-03-01T00:00:00+0300",
"include_lower": true,
"include_upper": true,
"boost": 1.0
}
}
},
"aggs": {
"sale_date": {
"date_histogram": {
"field": "date",
"interval": "day"
}
}
}
}
Returns:
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 0,
"max_score": 0.0,
"hits": []
},
"aggregations": {
"sale_date": {
"buckets": []
}
}
}