opensearch-project / OpenSearch

🔎 Open source distributed and RESTful search engine.
https://opensearch.org/docs/latest/opensearch/index/
Apache License 2.0
9.84k stars 1.83k forks source link

Make timezone in "strict_date_time" format optional #16701

Open peteralfonsi opened 12 hours ago

peteralfonsi commented 12 hours ago

Description

Changes "strict_date_time" format to make the timezone optional. For example, 2024-06-01T13:38:18.280 was not previously allowed, only 2024-06-01T13:38:18.280Z or 2024-06-01T13:38:18.280Z+00:00. If there's no timezone, it defaults to UTC. This is useful as Python's isoformat() can output times like this, and they are ISO 8601 compliant.

Adds UT. Also tested manually with the mapping:

"timestamp":    { 
    "type" : "date", 
    "format":"strict_date_time" 
} 

and indexing two documents, one with timestamp "2023-01-01T14:14:14Z" and one with "2023-01-01T14:14:14". In the existing code, the second one failed with RequestError(400, 'mapper_parsing_exception', "failed to parse field [timestamp] of type [date] in document with id '2'. Preview of field's value: '2023-02-02T14:14:14'").

After this change, both are accepted.

Related Issues

Resolves https://github.com/opensearch-project/OpenSearch/issues/16673

Check List

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. For more information on following Developer Certificate of Origin and signing off your commits, please check here.

github-actions[bot] commented 11 hours ago

:x: Gradle check result for d54ff3c3fbfd670ce92fa0120e8b82b57f5d769f: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?