Open
Description
Describe the bug
When performing sum aggregation on a field which doesn't exist in all the documents or all documents have explicit null value for that field, the aggregation result shows 0
, which is not as expected, null
makes more sense. And you can see that, the avg/max/min aggregation returns null.
Request:
GET test1/_search
{
"size": 0,
"aggs": {
"stats-agg": {
"stats": {
"field": "a"
}
}
}
}
result:
{
"took": 4,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 3,
"relation": "eq"
},
"max_score": null,
"hits": []
},
"aggregations": {
"stats-agg": {
"count": 0,
"min": null,
"max": null,
"avg": null,
"sum": 0
}
}
}
Related component
Search:Aggregations
To Reproduce
- DELETE test1
PUT test1/_mapping
{
"properties":{
"a":{
"type":"integer"
}
}
}
POST test1/_doc?refresh
{
"a":null
}
- Check the result
GET test1/_search
{
"size": 0,
"aggs": {
"stats-agg": {
"stats": {
"field": "a"
}
}
}
}
Expected behavior
Sum aggregation returns null rather than 0 for the case that all documents have null values for the field the aggregation performs on.
Additional Details
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
🆕 New