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!!!
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.