-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Closed
Labels
Description
Elasticsearch version (bin/elasticsearch --version):
7.2.0
Description of the problem including expected versus actual behavior:
Passing a time_zone parameter in a date_histogram source in composite aggregation returns wrong buckets.
It has been reported in this discussion some months ago, but the problem is still present in master: https://discuss.elastic.co/t/composite-date-aggregation-not-consistent/172666
Steps to reproduce:
# Create index
curl -XPUT "http://elastic:9200/test_date_histo" -H 'Content-Type: application/json' -d'
{
"settings": {
"number_of_shards": 5
},
"mappings": {
"properties": {
"date": {
"type": "date"
}
}
}
}'
# Index some data
curl -XPOST "http://elastic:9200/test_date_histo/_doc" -H 'Content-Type: application/json' -d'
{
"date": "2019-03-01T00:01:00+00:00"
}'
# Perform a comparative query
curl -XGET "http://elastic:9200/test_date_histo/_search?request_cache=false" -H 'Content-Type: application/json' -d'
{
"size": 0,
"aggs": {
"date_histo": {
"date_histogram": {
"field": "date",
"interval": "1d",
"time_zone": "+02:00",
"format": "yyyy-MM-dd"
}
},
"composite_date_histo": {
"composite": {
"sources": [
{
"date_histo": {
"date_histogram": {
"field": "date",
"interval": "1d",
"format": "yyyy-MM-dd",
"time_zone": "+02:00"
}
}
}
]
}
}
}
}'
The result is:
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 0.0,
"hits" : [ ]
},
"aggregations" : {
"composite_date_histo" : {
"after_key" : {
"date_histo" : "2019-02-28"
},
"buckets" : [
{
"key" : {
"date_histo" : "2019-02-28"
},
"doc_count" : 1
}
]
},
"date_histo" : {
"buckets" : [
{
"key_as_string" : "2019-03-01",
"key" : 1551391200000,
"doc_count" : 1
}
]
}
}
}