I'm trying to send the following JSON input to elasticsearch but I'm obtaining a parser error.
This the JSON input
{
"chassisNumber": "654321",
"position": "40.480143, -3.688960",
"issue": "Position",
"timestamp": "2016-07-15T15:29:50+02:00[Europe/Paris]"
}
the Index definition
{
"mappings":{
"vehicle":{
"properties":{
"vehicle":{
"type":"string"
},
"position":{
"type": "geo_point"
},
"issue":{
"type":"string"
},
"timestamp":{
"type":"date",
"format":"YYYY-MM-DD'T'HH:mm:ssZ"
}
}
}
}
}
And the error associated with the "timestamp" field.
"reason": "Invalid format: \"2016-07-15T15:29:50+02:00[Europe/Paris]\" is malformed at \"[Europe/Paris]\""
I tried with a few date formats but no one was success. Can anybody help me to define the correct format to parse the "timestamp" field in elasticsearch?
Thanks!!!
Date field typeedit. JSON doesn't have a date data type, so dates in Elasticsearch can either be: strings containing formatted dates, e.g. "2015-01-01" or "2015/01/01 12:10:30" . a number representing milliseconds-since-the-epoch.
dd – two-digit day of the month, e.g. 02. ddd – three-letter abbreviation for day of the week, e.g. Fri. dddd – day of the week spelled out in full, e.g. Friday.
As you can see in the mapping that your field timestamp
is mapped as date
type with format YYYY-MM-DD'T'HH:mm:ssZ
. So, Elasticsearch would want the timestamp
field to be passed in same format. The data you are passing is 2016-07-15T15:29:50+02:00[Europe/Paris]
which includes [Europe/Paris]
after zone data which is not given in mapping and does not follow default ISO 8601
format supported by Elasticsearch (more data available here).
You can read more on default date format supported by Elasticsearch here.
So either you have to remove extra data passed to Elasticsearch and keep it according to mapping
{
"chassisNumber": "654321",
"position": "40.480143, -3.688960",
"issue": "Position",
"timestamp": "2016-07-15T15:29:50+02:00"
}
or change your mapping to custom date format which follows the joda syntax defined here. In your case if it is literal zone required you have to use z
too.
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