ES query sorting by date with custom missing value

I have an index containing some documents with a date field:

"date": {
  "type": "date",
  "format": "date_optional_time"

The field is optional (some documents don't have that value).

I would like to run a query returning all documents sorted by the date field and setting missing value to some specific custom date.

Apparently in case of type date, missing value needs to be of type long which I guess is a timestamp in milliseconds.

My question is: What timezone to use when preparing a custom value?

It is not obvious for me since, when storing documents, I can pass dates as strings in a timezone-agnostic format.

If ES internally converts such strings to timestamps, then to prepare a custom missing date I would have to use the same timezone that ES uses for such conversions.

(It was tested on ES 5.6.9.)

Kind regards,

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