opensearch-project / OpenSearch

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

[BUG] Dynamic Mapping interprets "1406-21" as a [date] field. #9635

Open ungeordnet opened 1 year ago

ungeordnet commented 1 year ago

Describe the bug Dynamic mapping interprets a string with this format 1406-21 as a date field, but then it fails to index due to 21 not being a valid month.

To Reproduce Steps to reproduce the behavior:

  1. PUT /bug_report
  2. POST /bugreport/_doc
    {
    "not_a_date": "1406-21"
    }
  3. {
    "error": {
    "root_cause": [
      {
        "type": "date_time_exception",
        "reason": "date_time_exception: Invalid value for MonthOfYear (valid values 1 - 12): 21"
      }
    ],
    "type": "mapper_parsing_exception",
    "reason": "failed to parse field [not_a_date] of type [date] in document with id 'ikxsRYoBwHActdbCw803'. Preview of field's value: '1406-21'",
    "caused_by": {
      "type": "date_time_exception",
      "reason": "date_time_exception: Invalid value for MonthOfYear (valid values 1 - 12): 21"
    }
    },
    "status": 400
    }

Expected behavior The insert of the new document succeeds

Host/Environment (please complete the following information):

ungeordnet commented 1 month ago

Any updates on that issue?

dblock commented 1 month ago

@ungeordnet I don't think anyone is working on this. Want to try to help? Start by writing a YAML REST test and then a lower level unit test that reproduces the issue?