ElasticSearch Spring-Data Date format always is long

I would suggest to give a try to existing mappings available if they suffice the need. With es version: 7.14.1, following works quite well:

@Field(type = FieldType.Date, format = DateFormat.basic_date_time)
private Date creationTime;

Good thing is one doesn't have to worry about mappings, as it's automatically created. It might be supported in older versions, which I haven't checked.


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