Skip to content

[6.8] Incorrect week based parsing with java.time #58602

@pgomulka

Description

@pgomulka

related to this bug #41670 and fixed in v7.6+ PR fix #48349
affecting 6.8

week based dates are parsed in java.time with Sunday,1 calendar data rule. We cannot change this with java.locale.providers as that flag allows using SPI since jdk9+ (jdk8 is supported in 6.8)

reproduce

curl --request PUT \
  --url http://localhost:9200/test \
  --header 'authorization: Basic ZWxhc3RpYzpwYXNzd29yZA==' \
  --header 'content-type: application/json' \
  --data '{
	"mappings" :{

			"properties": {
				"timestamp": {
					"type": "date",
						"format":"YYYY-ww",
					"store": true
					}
			}
		}

}'
curl --request POST \
  --url http://localhost:9200/test/_doc \
  --header 'authorization: Basic ZWxhc3RpYzpwYXNzd29yZA==' \
  --header 'content-type: application/json' \
  --data '{
	"timestamp": "2020-33"
	
}'

results in

{
  "error": {
    "root_cause": [
      {
        "type": "mapper_parsing_exception",
        "reason": "failed to parse field [timestamp] of type [date] in document with id 'Q9-p5XIBy0lAoBkyOJdN'"
      }
    ],
    "type": "mapper_parsing_exception",
    "reason": "failed to parse field [timestamp] of type [date] in document with id 'Q9-p5XIBy0lAoBkyOJdN'",
    "caused_by": {
      "type": "illegal_argument_exception",
      "reason": "temporal accessor [{WeekBasedYear[WeekFields[SUNDAY,1]]=2020, WeekOfWeekBasedYear[WeekFields[SUNDAY,1]]=33},ISO] cannot be converted to zoned date time"
    }
  },
  "status": 400
}

and since 7.6 it returns fine.

then when searching

curl --request GET \
  --url http://localhost:9200/test/_search \
  --header 'authorization: Basic ZWxhc3RpYzpwYXNzd29yZA==' \
  --header 'content-type: application/json' \
  --data '{
	  "stored_fields": [ "timestamp" ] 
}'

correct

{
  "took": 4,
  "timed_out": false,
  "_shards": {
    "total": 1,
    "successful": 1,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": {
      "value": 1,
      "relation": "eq"
    },
    "max_score": 1.0,
    "hits": [
      {
        "_index": "test",
        "_type": "_doc",
        "_id": "1Pqe5XIB1L6riJIjbO85",
        "_score": 1.0,
        "fields": {
          "timestamp": [
            "2020-33"
          ]
        }
      }
    ]
  }
}

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