-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Closed
Labels
Description
This bug is present in at least 7.6. Probably earlier.
composite agg does not behave the same as date_histogram on a date_nanos field.
Example:
Lets build a date_nanos index with some docs
PUT mah_nano
{
"mappings": {
"properties": {
"@timestamp": {
"type": "date_nanos"
}
}
}
}
POST mah_nano/_doc
{
"@timestamp": "2019-07-15T16:50:31+00:00"
}
POST mah_nano/_doc
{
"@timestamp": "2019-07-16T16:50:31+00:00"
}
POST mah_nano/_doc
{
"@timestamp": "2019-07-17T16:50:31+00:00"
}
POST mah_nano/_doc
{
"@timestamp": "2019-07-17T16:55:31+00:00"
}
A good call from a date_histogram agg:
GET mah_nano/_search?size=0
{
"aggs": {
"buckets": {
"date_histogram": {
"field": "@timestamp",
"calendar_interval": "day"
},
"aggs": {
"avg": {
"avg": {
"field": "@timestamp"
}
}
}
}
}
}
Returns:
"aggregations" : {
"buckets" : {
"buckets" : [
{
"key_as_string" : "2019-07-15T00:00:00.000Z",
"key" : 1563148800000,
"doc_count" : 1,
"avg" : {
"value" : 1.563209431E12,
"value_as_string" : "2019-07-15T16:50:31.000Z"
}
},
{
"key_as_string" : "2019-07-16T00:00:00.000Z",
"key" : 1563235200000,
"doc_count" : 1,
"avg" : {
"value" : 1.563295831E12,
"value_as_string" : "2019-07-16T16:50:31.000Z"
}
},
{
"key_as_string" : "2019-07-17T00:00:00.000Z",
"key" : 1563321600000,
"doc_count" : 2,
"avg" : {
"value" : 1.563382381E12,
"value_as_string" : "2019-07-17T16:53:01.000Z"
}
}
]
}
But, the following composite agg does not return the same thing:
GET mah_nano/_search?size=0
{
"aggs": {
"buckets": {
"composite": {
"sources": [
{
"timestamp": {
"date_histogram": {
"field": "@timestamp",
"calendar_interval": "day"
}
}
}
]
},
"aggs": {
"avg": {
"avg": {
"field": "@timestamp"
}
}
}
}
}
}
There are instead strange null values and bucket keys
"aggregations" : {
"buckets" : {
"after_key" : {
"timestamp" : 1563382530921600000
},
"buckets" : [
{
"key" : {
"timestamp" : 1563209430940800000
},
"doc_count" : 1,
"avg" : {
"value" : null
}
},
{
"key" : {
"timestamp" : 1563295830940800000
},
"doc_count" : 1,
"avg" : {
"value" : null
}
},
{
"key" : {
"timestamp" : 1563382230940800000
},
"doc_count" : 1,
"avg" : {
"value" : null
}
},
{
"key" : {
"timestamp" : 1563382530921600000
},
"doc_count" : 1,
"avg" : {
"value" : null
}
}
]
}
}