0

I create ElasticSearch (7.7 version) index (with mappings) in cdk script. here is my mapping for the date field:

{
  "mappings": {
    "numeric_detection": true,
    "properties": {
      "approximateArrivalTime": {
        "type": "date",
        "format": "yyyy-MM-dd HH:mm:ss.SSSXXX"
      }, ......} 

But I keep having this error message:

  {\"type\":\"illegal_argument_exception\",\"reason\":\"failed to parse date field [2020-11-23 11:48:20.472] with format [yyyy-MM-dd HH:mm:ss.SSSXXX]\",\"caused_by\":{\"type\":\"date_time_parse_exception\",\"reason\":\"Text \\u00272020-11-23 11:48:20.472\\u0027 could not be parsed at index 23\"}}}

What could be the reason?

1 Answer 1

1

The error clearly indicates that the data you are indexing in the approximateArrivalTime does not match with that of your date format specified in the index mapping.

Try indexing the document in the below format:

Index Mapping:

{
  "mappings": {
    "properties": {
      "approximateArrivalTime": {
       "type": "date",
       "format": "yyyy-MM-dd HH:mm:ss.SSS"
        }
    }
  }
}

Index Data:

{
  "approximateArrivalTime":"2020-11-23 11:48:20.472"
}
Sign up to request clarification or add additional context in comments.

10 Comments

@A.Di did you get a chance to go through my answer, looking forward to get feedback from you :)
thanx for your answer, unfortunately, it didn't help. still the same error.
@A.Di I tried it locally also, and it's working fine. Can you please share the data you are indexing for approximateArrivalTime? And are you getting the error when running a search query on approximateArrivalTime ?
2020-11-23 11:48:20.472 - I try to parse this date. The error says it cannot parse this field when I provide the field type in mappings. So I guess tries index data and then fails.
@A.Di You are indexing the same doc 2020-11-23 11:48:20.472 that you have provided in the question above. Please go through my answer, the data that you are indexing does not match with the date format you have mentioned in the index mapping. And therefore, you are getting parsing error
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.