opensearch-java icon indicating copy to clipboard operation
opensearch-java copied to clipboard

[BUG] Range queries are inconsistent with documentation

Open prudhvigodithi opened this issue 3 years ago • 6 comments

Describe the bug Using opensearch-rest-high-level-client 1.2.0 in java code behaves differently as compared to range query documentation. Using the following code:

boolQueryBuilder.filter(QueryBuilders.rangeQuery("created_at").gte(startDate).lte(endDate));

The query is created as

"filter": [
  {
    "range": {
      "created_at": {
        "from": "2022-11-07",
        "to": "2023-02-07",
        "include_lower": true,
        "include_upper": true,
        "boost": 1
      }
    }
  }

Expected behavior Should it be creating as gte and lte ?

Plugins N/A

Screenshots If applicable, add screenshots to help explain your problem.

Host/Environment (please complete the following information):

  • OS: OpenSearch 1.1 (Amazon opensearch service)

prudhvigodithi avatar Feb 08 '23 17:02 prudhvigodithi

Is this fixed/changed in main? Or with opensearch-java?

dblock avatar Feb 09 '23 16:02 dblock

@dblock I believe those are equivalent:

"filter": [
  {
    "range": {
      "created_at": {
        "gte": "2022-11-07",
        "lte": "2023-02-07",
        "boost": 1
      }
    }
  }

The gte and lte are transformed to to / from, include_lower / include_upper. Both queries are valid.

reta avatar Feb 09 '23 17:02 reta

@prudhvigodithi If @reta is correct, is this still an issue?

I do feel like if I use gte I'd expect to see gte, and if I use to I'd expect to :)

dblock avatar Feb 10 '23 19:02 dblock

Hey @reta thanks for clarifying, ya since i used gte in code it should show as gte in the result query, but as long both the queries are valid I'm good, should we consider updating the documentation ? @dblock @bbarani

prudhvigodithi avatar Feb 10 '23 19:02 prudhvigodithi

should we consider updating the documentation ?

@prudhvigodithi We could add more examples I believe

reta avatar Feb 10 '23 19:02 reta

I can create a PR in documentation website with this example.

prudhvigodithi avatar Feb 10 '23 21:02 prudhvigodithi