liotur
liotur

Reputation: 923

Elasticsearch (7.3) date mapping parsing failures

I have upgraded elasticsearch from 6.2.3 to 7.3

The mapping in ES looks like this:

"completion_date" : {
          "type" : "date",
          "store" : true,
          "format" : "yyyy-MM-dd'T'HH:mm:ss.SSSZ||yyyy-MM-dd'T'HH:mm:ssZ||yyyy-MM-dd"
        }

Failing with bellow exception:

Elasticsearch exception [type=mapper_parsing_exception, reason=failed to parse field [completion_date] in document ....4181937'. Preview of field's value: '2018-01-23T16:40:00.000Z']

Could you please help me, explain why does it happen, and how I could fix that?

Upvotes: 2

Views: 313

Answers (1)

Luc Ebert
Luc Ebert

Reputation: 1255

I agree with you, i tried it and noticed that it works in ES6 but not in ES7. However, it seems to work if you put the following format :

"format" : "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"

But i don't think it is the best solution since it is not specified like this in the documentation (maybe they will update it later). For me, the best solution is to call the format with their name, as specified in the documentation : es doc

So your mapping should look something like this :

"completion_date" : {
      "type" : "date",
      "store" : true,
      "format" : "strict_date_time||strict_date_time_no_millis||strict_date"
    }

Hope that helps!

Upvotes: 4

Related Questions