Closed
Description
I've noticed that if a field is Instant
with epoch_millis
format:
@Field(type = FieldType.Date, format = DateFormat.epoch_millis)
private Instant timestamp;
spring-data-elasticsearch will convert this object as a json with string value like "timestamp":"1644234181000"
rather than long value "timestamp":1644234181000
. After digging into the code, I find that it's DateFormatter#format
that returns only string value, so timestamp in Instant
is converted into a string value rather long.
- Although string value(long literally) for
epoch_mills
is accepted by elasticsearch, it's not mentioned in the doc; - Worse, we save/update our value as long for
epoch_millis
before(without using spring-data-elasticsearch), so now after using spring-data-elasticsearch, both string and long exist fortimestamp
field; - Additionally, we also use elasticsearch-hadoop to read data in elasticsearch, and it can only read
epoch_millis
as long or string, not both.
Any ideas to support to convert epoch_millis
and epoch_second
for date type as long rather than string? or at least supply an option to determine it as long or string, rather than just use string whatever the real date type is.