Skip to content

Elasticsearch 7 reports a different key_as_string for dayOfWeek for date_histogram aggs than Elasticsearch 6 did #43275

Closed
@centic9

Description

@centic9

Elasticsearch version (bin/elasticsearch --version): 6.7.2 and 7.1.1

Plugins installed: []

JVM version (java -version): Java HotSpot(TM) 64-Bit Server VM/11.0.1/11.0.1+13-LTS

OS version (uname -a if on a Unix-like system): Windows 10

Description of the problem including expected versus actual behavior:

We are looking at upgrading from Elasticsearch 6.x to 7.x and one of our tests related to day-of-week in date-histogramm aggregations is failing. When investigating a bit more we found that there is actually a different response for the "key_as_string" for buckets of a date_histogramm aggregation which aggregates on "day of week" in Elasticsearch 7 compared to Elasticsearch 6.

I could not find any "breaking change" mentioned for this, so I believe this may be an unintended side-effect of switching from Joda Time to Java DateTime API (https://www.elastic.co/guide/en/elasticsearch/reference/7.0/breaking-changes-7.0.html#breaking_70_java_time_changes)?

Steps to reproduce:

curl -X PUT "localhost:9200/twitter/_doc/1" -H 'Content-Type: application/json' -d'
{
    "user" : "kimchy",
    "post_date" : "2009-11-15T14:12:12",
    "message" : "trying out Elasticsearch"
}
'
curl -XPOST 'http://localhost:9200/twitter/_search' -d '{
 "size": 0,
 "aggregations": {
  "q2": {
   "date_histogram": {
    "field": "post_date",
    "format": "e",
    "interval": "day",
    "offset": 0
   }
  }
 }
}'

On Elasticsearch 6.7.2 this returns:

{
  "took": 2,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": 1,
    "max_score": 0,
    "hits": [

    ]
  },
  "aggregations": {
    "q2": {
      "buckets": [
        {
          "key_as_string": "7",
          "key": 1258243200000,
          "doc_count": 1
        }
      ]
    }
  }
}

however on Elasticsearch 7.1.1 is returns (note the difference in "key_as_string":

{
  "took": 1,
  "timed_out": false,
  "_shards": {
    "total": 1,
    "successful": 1,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": {
      "value": 1,
      "relation": "eq"
    },
    "max_score": null,
    "hits": [

    ]
  },
  "aggregations": {
    "q2": {
      "buckets": [
        {
          "key_as_string": "1",
          "key": 1258243200000,
          "doc_count": 1
        }
      ]
    }
  }
}

Provide logs (if relevant):

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions