Range query not giving right result for lte

The result includes 23/03 in the result and miss to show 17/04. Where in data is present in the system. Any help is appreciated.

    "range" : {
      "timestamp" : {
        "from" : "2021-03-23",
        "to" : "2021-04-17",
        "include_lower":true,
        "include_upper":true,
        "boost":1.0
      }
    }

I think that 2021-04-17 is actually parsed as 2021-04-17T00:00:00.
When you include it, it does not mean that any second after 00:00:00 will be matching.

You should either do:

    "range" : {
      "timestamp" : {
        "from" : "2021-03-23",
        "to" : "2021-04-17T23:59:59.999",
        "include_lower":true,
        "include_upper":true,
        "boost":1.0
      }
    }

But I definitely prefer:

    "range" : {
      "timestamp" : {
        "from" : "2021-03-23",
        "to" : "2021-04-18"
      }
    }
1 Like

Can you suggest how do we implement in Java using QueryBuilders.rangeQuery.

Thanks @dadoonet :slight_smile:
I will try with the suggested change.

Here is one:

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