When using spring-data to insert Elasticsearch document with Date type, I can\'t get right date format, the date format always is Long.
here is the java code: Entity.jav
Something to keep in mind:
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 long number representing milliseconds-since-the-epoch.
- An integer representing seconds-since-the-epoch.
Also from the same doc:
Dates will always be rendered as strings, even if they were initially supplied as a long in the JSON document
This implies that querying the data type for a date field will always be a string, a long or an integer. There is no special "Date" field in elastic search.
Read more here: https://www.elastic.co/guide/en/elasticsearch/reference/current/date.html