I have an index with a time field whose values are like:
time: 2012-06-02T12:25:27+02:00
Then I’m running 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
}
That is returning 0 hits, but if I shift the query string by 2 hours then it matches with the records in that time. So, I’m pretty sure this is a time zone problem. Reading the docs I found I can put a “time_zone” : 2 in the query, but…. where should it be placed in the previous query? I tried many options but couldn’t make it work.
You, probably, have seen the “time_zone” parameter in the histogram date facet, which is different from this query. The query_string query doesn’t accept a time_zone parameter. I think the simplest solution here would be replacing “Z” with desired time zone in your query: