Elasticsearch - Sort of Date fields using epoch_millis

Hi all,
I have stored date fields in Epoch_millis format but as a string
eg. {
"date" : "1543257000000"
}

Will this affect my sort query?
"sort" : [
{ "Date" : {"order" : "desc"}}

]

it depends if you have dates with different length (like around 1970) and negative dates, as ascii sorting would be a bit different than time based sorting in that case.

Have you considered using the reindex API to fix this (along with your ingestion pipeline)?

--Alex

Thanks for your time and answer.
But won't elasticsearch coerce it by default? Coerce functionality is applied by default and this should work fine while sorting.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.