1

Below query when executed in Elasticsearch version 1.x

Was considering documents created after 6/15/2016 that is documents which have time beyond 12 Am for the date 6/15/2016.It was considering documents till 6/15/2016 23:59:59.999 .

But with new version of ES 2.x the range query has stopped considering documents which have time beyond 12 Am for the date 6/15/2016. Now It is considering documents till 6/14/2016 23:59:59.999.

What exactly changed here?

{
 "from": 0,
 "size": 10,
 "sort": [
   {
     "PRONumber.sort": {
       "order": "desc"
     }
   }
 ],
 "query": {
   "bool": {
     "must": [
       {
         "match": {
           "BOLNumber": {
             "query": "7861254",
             "analyzer": "gtz_search_analyzer",
             "operator": "and"
           }
         }
       },
       {
         "range": {
           "CreatedDate": {
             "gte": "1753-01-01",
             "lte": "2016-06-15"
           }
         }
       }
     ]
   }
 }
}
1
  • If I remember correctly, you have to add it inside the must section or other boolean sections. Commented Jul 12, 2016 at 13:41

1 Answer 1

3

In elasticsearch 2.x for the query in the OP the upper-limit is 6/15/2016 00:00:00.000 and not 6/14/2016 23.59.59.999.
From the documentation it follows that you would need to explictly specify in the query to round-up by day as shown in the example below

Example:

{
 "from": 0,
 "size": 10,
 "sort": [
   {
     "PRONumber.sort": {
       "order": "desc"
     }
   }
 ],
 "query": {
   "bool": {
     "must": [
       {
         "match": {
           "BOLNumber": {
             "query": "7861254",
             "analyzer": "gtz_search_analyzer",
             "operator": "and"
           }
         }
       },
       {
         "range": {
           "CreatedDate": {
             "gte": "1753-01-01",
             "lte": "2016-06-15||/d"
           }
         }
       }
     ]
   }
 }
}
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks!. I think earlier in 1.x the upper limit was 6/15/2016 23.59.59.999 not 6/14/2016 23.59.59.999.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.