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
Your mapping is created correctly. The problem is more likely to come from the Jackson JSON serializer. You should try adding this annotation to your date fields: @JsonFormat (shape = JsonFormat.Shape.STRING, pattern ="yyyy-MM-dd'T'HH:mm:ss.SSSZZ")
.
There are also some alternative solutions that might better suit your case (i.e. creating a CustomDateSerializer
, etc).