Skip to content

Commit

Permalink
Checking if upper and lower terms are valid
Browse files Browse the repository at this point in the history
Signed-off-by: Harsha Vamsi Kalluri <[email protected]>
  • Loading branch information
harshavamsi committed Apr 29, 2024
1 parent 40de7c2 commit 6d24db6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -318,14 +318,17 @@ public Query rangeQuery(Object lowerTerm, Object upperTerm, boolean includeLower

}

lowerTerm = indexedValueForSearch(lowerTerm);
upperTerm = indexedValueForSearch(upperTerm);

if (lowerTerm == upperTerm) {
if (!includeLower || !includeUpper) {
return new MatchNoDocsQuery();
}
return termQuery(lowerTerm, context);
return termQuery(lowerTerm.equals(Values.TRUE), context);
}

if ((boolean) lowerTerm) {
if (lowerTerm.equals(Values.TRUE)) {
return new MatchNoDocsQuery();
}
if (!includeLower && !includeUpper) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ public void testRangeQuery() {
assertEquals(new TermQuery(new Term("field", "F")), ft.rangeQuery(null, false, true, true, null));

assertEquals(new DocValuesFieldExistsQuery("field"), ft.rangeQuery(false, null, true, true, null));

IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> ft.rangeQuery("random", null, true, true, null));

assertEquals("Can't parse boolean value [random], expected [true] or [false]", e.getMessage());
}

public void testFetchSourceValue() throws IOException {
Expand Down

0 comments on commit 6d24db6

Please sign in to comment.