Elastic search and time zones

I have an index with a time field whose values ​​are equal:

time: 2012-06-02T12:25:27+02:00

Then I run the following query:

{
  "sort": {
    "time": "desc"
  },
  "query": {
    "query_string": {
      "query": "time:[2012-6-2T12:24:00Z TO 2012-6-2T12:26:00Z]",
      "default_operator": "AND"
    }
  },
  "size": 30
}

This returns 0 hits, but if I shift the query string by 2 hours, it will match the records for that time. Therefore, I am sure that this is a time zone problem. Reading the documents that I found, I can put "time_zone": 2 in the request, but .... where should it be placed in the previous request? I tried many options, but could not get it to work.

+5
source share
1 answer

, "time_zone" , . query_string time_zone. , "Z" :

{
  "sort": {
    "time": "desc"
  },
  "query": {
    "query_string": {
      "query": "time:[2012-6-2T12:24:00+02:00 TO 2012-6-2T12:26:00+02:00]",
      "default_operator": "AND"
    }
  },
  "size": 30
}
+6

All Articles