I am trying to index data with a date format of Tue May 14 17:06:01 PDT 2013 . As described in the Elasticsearch Date Format document, I need to use a custom date format. I am referring to a DateTimeFormat document, and the corresponding format is EM d H:m:sz Y
I can create a mapping, but when I try to index the data, it gives me an error.
Mapping: -
{ "tweet": { "properties": { "user": { "type": "string", "index": "not_analyzed" }, "message": { "type": "string", "null_value": "na" }, "postDate": { "type": "date", "format": "EM d H:m:sz Y" }, "priority": { "type": "integer" }, "rank": { "type": "float" } } } }
Index document: -
curl -XPUT 'http://localhost:9200/tweets/tweet/1' -d '{ "user" : "kimchy", "message" : "This is a tweet!", "postDate" : "Tue May 14 17:06:01 PDT 2013", "priority" : 4, "rank" : 12.3 }'
Error: -
{"error":"MapperParsingException[failed to parse [postDate]]; nested: MapperParsingException[failed to parse date field [Tue May 14 17:06:01 PDT 2013], tried both date format [EM d H:m:sz Y], and timestamp number with locale []]; nested: IllegalArgumentException[Invalid format: \"Tue May 14 17:06:01 PDT 2013\" is malformed at \"May 14 17:06:01 PDT 2013\"]; ","status":400}
Any suggestion?
source share