Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

time_zone parameter in composite aggregation with date_histogram source doesn't work #45199

Closed
clement-tourriere opened this issue Aug 5, 2019 · 2 comments · Fixed by #51172

Comments

@clement-tourriere
Copy link

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
        }
      ]
    }
  }
}
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-analytics-geo

@dliappis dliappis added the >bug label Aug 5, 2019
@Cliffzz
Copy link

Cliffzz commented Jan 13, 2020

Is there any news on this? Without time_zone support composite date_histogram queries are nearly useless to us.

nik9000 added a commit to nik9000/elasticsearch that referenced this issue Jan 17, 2020
We've been parsing the `time_zone` parameter on `date_hitogram` for a
while but it hasn't *done* anything. This wires it up.

Closes elastic#45199
Inspired by elastic#45200
nik9000 added a commit that referenced this issue Jan 27, 2020
We've been parsing the `time_zone` parameter on `date_hitogram` for a
while but it hasn't *done* anything. This wires it up.

Closes #45199
Inspired by #45200
nik9000 added a commit to nik9000/elasticsearch that referenced this issue Jan 27, 2020
We've been parsing the `time_zone` parameter on `date_hitogram` for a
while but it hasn't *done* anything. This wires it up.

Closes elastic#45199
Inspired by elastic#45200
nik9000 added a commit to nik9000/elasticsearch that referenced this issue Jan 27, 2020
We've been parsing the `time_zone` parameter on `date_hitogram` for a
while but it hasn't *done* anything. This wires it up.

Closes elastic#45199
Inspired by elastic#45200
nik9000 added a commit that referenced this issue Jan 27, 2020
We've been parsing the `time_zone` parameter on `date_hitogram` for a
while but it hasn't *done* anything. This wires it up.

Closes #45199
Inspired by #45200
nik9000 added a commit that referenced this issue Feb 11, 2020
We've been parsing the `time_zone` parameter on `date_hitogram` for a
while but it hasn't *done* anything. This wires it up.

Closes #45199
Inspired by #45200
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants