Find Dates with offset

Hello, hopefully someone can help me on this.

Consider the following mapping

  "dateOfBirth": {
    "properties": {
      "value": {
        "type": "date",
        "format": "dateOptionalTime"

And for the above mapping i have the following data
doc1 => dateOfBirth.value = 2020-10-21T08:00:00.000+00:00
doc2 => dateOfBirth.value = 2020-01-05T10:00:00.000+02:00
doc3 => dateOfBirth.value = 2020-09-15T08:00:00.000+05:00
doc4 => dateOfBirth.value = 2020-05-03T11:00:00.000+02:00
doc5 => dateOfBirth.value = 2020-10-31T12:00:00.000+03:00

Is is possible to build a query that can find all dates that have an offset, for example:
Find all dates with offset +02:00


I don't think you can with this mapping. I believe that the only way is to index the field as a text field in addition to the date type.

Better, I'd try to solve that problem at index time by parsing the text on the client side or using an ingest pipeline with a Script Processor and add a field like:

  "dateOfBirth": "2020-10-21T08:00:00.000+00:00",
  "hasOffset": false

Thanks for the quick reply.
We were avoiding changing the mapping (live system), but as per your reply, we have no other choice.

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