I am trying to index data with date format Tue May 14 17:06:01 PDT 2013
. As described in Elasticsearch Date Format document I need to use custom date format. I refer to DateTimeFormat document and respective format is E M d H:m:s z Y
.
I am able to create mapping but when I am trying to index data its giving me error.
{
"tweet": {
"properties": {
"user": {
"type": "string",
"index": "not_analyzed"
},
"message": {
"type": "string",
"null_value": "na"
},
"postDate": {
"type": "date",
"format": "E M d H:m:s z Y"
},
"priority": {
"type": "integer"
},
"rank": {
"type": "float"
}
}
}
}
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":"MapperParsingException[failed to parse [postDate]];
nested: MapperParsingException[failed to parse date field [Tue May 14 17:06:01 PDT 2013],
tried both date format [E M d H:m:s z 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?
Advanced Settingsedit. Advanced Settings control the behavior of Kibana. For example, you can change the format used to display dates, specify the default data view, and set the precision for displayed decimal values. Open the main menu, then click Stack Management > Advanced Settings.
For Month use three 'M's. Quote from the API docs:
Month: 3 or over, use text, otherwise use number.
So the correct mapping for the input you provided should be:
"postDate": {
"type": "date",
"format": "E MMM d H:m:s z Y"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With