Hi there,
Having a hard time to parse a date with zone offset. I need to parse dates like this: "2020-05-07 13:16:44+00:00"
So far, I've tried:
PUT /_template/test
{
"index_patterns": ["test"],
"mappings": {
"properties": {
"date1": { "type": "date", "format": "yyyy-MM-dd HH:mm:ssZ" },
"date2": { "type": "date", "format": "yyyy-MM-dd HH:mm:ssZZ" },
"date3": { "type": "date", "format": "yyyy-MM-dd HH:mm:ssZZZ" },
"date4": { "type": "date", "format": "yyyy-MM-dd HH:mm:ssZZZZ" }
}
}
}
PUT /test/_doc/1
{ "date1": "2020-05-07 13:16:44+00:00" }
PUT /test/_doc/1
{ "date2": "2020-05-07 13:16:44+00:00" }
PUT /test/_doc/1
{ "date3": "2020-05-07 13:16:44+00:00" }
PUT /test/_doc/1
{ "date4": "2020-05-07 13:16:44+00:00" }
Every attempt fails because the date can't be parsed (example error for the first case, all looks the same).
{
"error" : {
"root_cause" : [
{
"type" : "mapper_parsing_exception",
"reason" : "failed to parse field [date1] of type [date] in document with id '1'. Preview of field's value: '2020-05-07 13:16:44+00:00'"
}
],
"type" : "mapper_parsing_exception",
"reason" : "failed to parse field [date1] of type [date] in document with id '1'. Preview of field's value: '2020-05-07 13:16:44+00:00'",
"caused_by" : {
"type" : "illegal_argument_exception",
"reason" : "failed to parse date field [2020-05-07 13:16:44+00:00] with format [yyyy-MM-dd HH:mm:ssZ]",
"caused_by" : {
"type" : "date_time_parse_exception",
"reason" : "Text '2020-05-07 13:16:44+00:00' could not be parsed at index 19"
}
}
},
"status" : 400
}
.....
Please, which is the right format I need to use?
Thank you very much.