opensearch-project / OpenSearch

🔎 Open source distributed and RESTful search engine.
https://opensearch.org/docs/latest/opensearch/index/
Apache License 2.0
9.1k stars 1.69k forks source link

[Feature Request] Supports RangeQueryBuilder lte, gte method provide "lte", "gte" operator, not "from", "to" #14249

Open roharon opened 1 month ago

roharon commented 1 month ago

Is your feature request related to a problem? Please describe

In OpenSearch 2.14.0.

When I define query with RangeQueryBuilder, gte and gt method defined query tofrom, and lteand lt method defined query to to.

I think defined query to gte, gt or lte, lt is more properly.

Describe the solution you'd like

When I write code as

RangeQueryBuilder("name").gte(LocalDate.of(2024, 6, 10)).lte(LocalDate.of(2024, 6, 13))

actual result is

{
  "range": {
    "name": {
      "from": "2024-06-10",
      "to": "2024-06-13",
      "include_lower": true,
      "include_upper": true,
    }
  }
}  

But I think this result should be like below.

{
  "range": {
    "name": {
      "gte": "2024-06-10",
      "lte": "2024-06-13"
    }
  }
}  

Related component

Libraries

Describe alternatives you've considered

No response

Additional context

No response

dblock commented 2 weeks ago

[Catch All Triage - Attendees 1, 2, 3, 4, 5]

msfroh commented 2 weeks ago

These are equal objects. Why does it matter what the JSON representation of a RangeQueryBuilder is?

The gt, lt, gte, and lte parameters are intended as a convenient short-hand for the more verbose from, to, include_lower, include_upper representations.

roharon commented 2 weeks ago

These are equal objects. Why does it matter what the JSON representation of a RangeQueryBuilder is?

The gt, lt, gte, and lte parameters are intended as a convenient short-hand for the more verbose from, to, include_lower, include_upper representations.

gt is same as setting from and include_lower to false. and also gte is same as setting from and include_lower to true. the same goes for lt,lte.

Even though, when defined query with gte, it would be expected, and more natural as gte not from and include_lower: true