-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Closed
Labels
Description
Elasticsearch version (bin/elasticsearch --version):
Version 6.2.2
Description of the problem including expected versus actual behavior:
Different metric aggregations are returning different values when none of the documents in the bucket contain the field used in the aggregation. avg, min and max for example return null, whereas the percentiles agg returns NaN. I would expect the return values to be consistent across aggregations, whether it be null or NaN.
Ran the following aggregations, where some buckets contained docs without the test.sslTime field.
avg agg:
"aggs": {
"2": {
"date_histogram": {
"field": "createdDate",
"interval": "15m",
"time_zone": "Europe/London",
"min_doc_count": 1
},
"aggs": {
"3": {
"terms": {
"field": "test.testId.keyword",
"size": 5,
"order": {
"_term": "desc"
}
},
"aggs": {
"1": {
"avg": {
"field": "test.sslTime"
}
}
}
}
}
}
}
Percentiles agg, to obtain the median:
"aggs": {
"2": {
"date_histogram": {
"field": "createdDate",
"interval": "15m",
"time_zone": "Europe/London",
"min_doc_count": 1
},
"aggs": {
"3": {
"terms": {
"field": "test.testId.keyword",
"size": 5,
"order": {
"_term": "desc"
}
},
"aggs": {
"1": {
"percentiles": {
"field": "test.sslTime",
"percents": [
50
],
"keyed": false
}
}
}
}
}
}
}
WIth example of the responses:
From the avg agg:
{
"3": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"1": {
"value": null
},
"key": "VAL1",
"doc_count": 6
}
]
},
"key_as_string": "2018-02-03T11:45:00.000Z",
"key": 1517658300000,
"doc_count": 6
}
and from the percentiles agg:
{
"3": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"1": {
"values": [
{
"key": 50,
"value": "NaN"
}
]
},
"key": "VAL1",
"doc_count": 6
}
]
},
"key_as_string": "2018-02-03T11:45:00.000Z",
"key": 1517658300000,
"doc_count": 6
}