I have a range aggregation over a query, the query returns zero hits, but the aggregation returns some of the buckets with values, looks to me like a Bug, not sure if this is expected behavior, I think it should not and if it is it results highly confusing and woulod appreciate help on clarifying why the behavior.
The range aggregation as follows:
"aggs": {
"sender_agg": {
"range": {
"field": "ownerId",
"ranges": [
{
"to": 140,
"key": "others-1"
},
{
"from": 140,
"to": 141,
"key": "140"
},
{
"from": 141,
"to": 145,
"key": "others-2"
},
{
"from": 145,
"to": 146,
"key": "145"
},
{
"from": 146,
"key": "others-3"
}
]
}
},
"score_agg": {
"stats": {
"script": "_score"
}
}
}
and the response is:
{
"took": 16,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"failed": 0
},
**"hits": {**
**"total": 0,**
**"max_score": null,**
**"hits": []**
**},**
"aggregations": {
"sender_agg": {
"buckets": [
{
**"key": "others-1",**
**"to": 140,**
**"to_as_string": "140.0",**
**"doc_count": 1**
},
{
**"key": "140",**
**"from": 140,**
**"from_as_string": "140.0",**
**"to": 141,**
**"to_as_string": "141.0",**
**"doc_count": 1**
},
{
**"key": "others-2",**
**"from": 141,**
**"from_as_string": "141.0",**
**"to": 145,**
**"to_as_string": "145.0",**
**"doc_count": 2**
},
{
"key": "145",
"from": 145,
"from_as_string": "145.0",
"to": 146,
"to_as_string": "146.0",
"doc_count": 0
},
{
"key": "others-3",
"from": 146,
"from_as_string": "146.0",
"doc_count": 0
}
]
},
"score_agg": {
"count": 4,
"min": 1,
"max": 1,
"avg": 1,
"sum": 4
}
}
}