I am trying to import a bunch of JSON documents that have dates with format:
2019-03-21T10:30:31.2Z
2018-10-26T23:42:27.3Z
2019-01-17T18:55:29.3Z
2018-09-15T11:26:16.1Z
2019-03-25T18:59:50.1Z
2019-03-04T00:21:27.1Z
which if I understand this page correctly
basic_ordinal_date_time
A formatter for a full ordinal date and time, using a four digit year and three digit dayOfYear:
yyyyDDD'T'HHmmss.SSSZ
.
Should match my dates.
On a brand new elasticsearch install, I get error:
ERROR 2019/04/19 09:53:37Bulk response item:
{
"_index":"upbedv2.alerts",
"_type":"_doc",
"_id":"iQRvaG2cT95KHG46y",
"status":400,
"error":{
"type":"mapper_parsing_exception",
"reason":"failed to parse field [date] of type [date] in document with id 'iQRvaG2cT95KHG46y'",
"caused_by":{
"caused_by":{
"reason":"Failed to parse with all enclosed parsers",
"type":"date_time_parse_exception"
},
"reason":"failed to parse date field [2018-12-04T22:02:58.7Z] with format [strict_date_optional_time||epoch_millis]",
"type":"illegal_argument_exception"
}
}
}
What is weird is that some of my documents made it into the index.
After googling I learn about dynamic dates, and think "maybe I need to specify an index template"
Via the kibana dev tools:
PUT _template/tpl
{
"template": "myindex.*",
"mappings": {
"dynamic_date_formats" : [
"basic_ordinal_date_time"
]
}
}
Now my dates are not being recognized when I look at the mapping for the index.
I noticed how some of the dates don't have the trailing zeros for the miliseconds. Thought this might help:
PUT _template/tpl
{
"template": "myindex.*",
"mappings": {
"dynamic_date_formats" : [
"basic_ordinal_date_time",
"yyyy-MM-dd'T'HH:mm:ss.SZ",
"yyyy-MM-dd'T'HH:mm:ss.SSZ",
"yyyy-MM-dd'T'HH:mm:ss.SSSZ"
]
}
}
Dates are still not recognized.
What am I missing?