Elasticsearch date format

I am trying to send the next JSON input to elasticsearch, but I am getting a parser error.

This input is JSON

{ "chassisNumber": "654321", "position": "40.480143, -3.688960", "issue": "Position", "timestamp": "2016-07-15T15:29:50+02:00[Europe/Paris]" } 

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 several date formats, but no one succeeded. Can someone help me determine the correct format for parsing the "timestamp" field in elasticsearch?

Thanks!!!

+5
source share
1 answer

As you can see in the display, your timestamp field is displayed as a date type with the format YYYY-MM-DD'T'HH:mm:ssZ . So Elasticsearch wants the timestamp field to be transmitted in the same format. The data you transfer is 2016-07-15T15:29:50+02:00[Europe/Paris] , which includes [Europe/Paris] after the zone data, which are not specified in the mapping, and do not conform to the default ISO 8601 supported by Elasticsearch (more data available here ).

Learn more about the default date format supported by Elasticsearch here .

So either you need to delete the extra data passed to Elasticsearch and save it according to the display

 { "chassisNumber": "654321", "position": "40.480143, -3.688960", "issue": "Position", "timestamp": "2016-07-15T15:29:50+02:00" } 

or change your mapping to a custom date format that follows the joda syntax defined here . In your case, if a literal zone is required, you also need to use z .

+4
source

All Articles