Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

elasticsearch failed to parse date

I've the following index definition for the date:

"handshaketime" : {"type":"date","format":"YYYY-MM-ddTHH:mm:ss.SSSZ"}

And the actual date is of this form:

"handshaketime":"2015-04-07T10:43:03.000-07:00"

I've specified that date coming from DB has the above mentioned format but elasticsearch still gives me the following error.

Caused by: org.elasticsearch.index.mapper.MapperParsingException: failed to
parse date field [2015-04-07T10:43:03.000-07:00], tried both date format
[YYYY-MM-dd HH:mm:ss], and timestamp number with locale []

I'm using elasticsearch 1.4.4 with jdbc_river 1.4.0.10.

Please tell me whats going on.

like image 235
BoCode Avatar asked Mar 18 '15 12:03

BoCode


2 Answers

In trying to fix this error, I came across the same result, despite what @Vineeth provided. I pointed to him that for some reason ES is not showing the format that we supplied but instead gives the same error over and over again.

Finally, I came across a post describing the removal of all indexes in ES and re-submitting our index/mapping document afresh (aka clean-slating). Voila! it worked, in fact it worked if i just gave the following:

"handshaketime":{"type":"date", "format": "dateOptionalTime"}

Not even custom format that me and @Vineeth were discussing about!!

So if you are struggling with this problem, make sure there are NO indexes in the ES that may be preventing you to index your new document.

Thanks for trying to sort this issue @Vineeth.

like image 62
BoCode Avatar answered Oct 21 '22 04:10

BoCode


You have to give it as follows - There should be single quotes for T as its not a time identifier.

 {"type":"date","format":"YYYY-MM-dd'T'HH:mm:ss.SSSZ"}

If you are using shell script , you need to give it as follows -

 {"type":"date","format":"YYYY-MM-dd'"'T'"'HH:mm:ss.SSSZ"}
like image 2
Vineeth Mohan Avatar answered Oct 21 '22 04:10

Vineeth Mohan