Skip to content

Commit b539cba

Browse files
committed
Updated tests to fit new query hierarchy
1 parent d3a0085 commit b539cba

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5252
- Approximation Framework Enhancement: Update the BKD traversal logic to improve the performance on skewed data ([#18439](https://github.com/opensearch-project/OpenSearch/issues/18439))
5353
- Support system generated ingest pipelines for bulk update operations ([#18277](https://github.com/opensearch-project/OpenSearch/pull/18277)))
5454
- Added FS Health Check Failure metric ([#18435](https://github.com/opensearch-project/OpenSearch/pull/18435))
55+
- Added approximation support for range queries with now in date field ([#18511](https://github.com/opensearch-project/OpenSearch/pull/18511))
5556

5657
### Changed
5758
- Create generic DocRequest to better categorize ActionRequests ([#18269](https://github.com/opensearch-project/OpenSearch/pull/18269)))

server/src/main/java/org/opensearch/index/mapper/DateFieldMapper.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,6 @@ public static Query handleNow(QueryShardContext context, Function<LongSupplier,
602602
}
603603

604604
return query;
605-
// return nowUsed[0] ? new DateRangeIncludingNowQuery(query) : query;
606605
}
607606

608607
public long parseToLong(Object value, boolean roundUp, @Nullable ZoneId zone, DateMathParser dateParser, LongSupplier now) {

server/src/test/java/org/opensearch/index/query/RangeQueryBuilderTests.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -440,14 +440,23 @@ public void testDateRangeQueryTimezone() throws IOException {
440440
+ " }\n"
441441
+ " }\n"
442442
+ "}";
443+
444+
// TODO what else can we assert
443445
QueryShardContext context = createShardContext();
444446
Query parsedQuery = parseQuery(query).toQuery(context);
445-
assertThat(parsedQuery, instanceOf(DateRangeIncludingNowQuery.class));
446-
parsedQuery = ((DateRangeIncludingNowQuery) parsedQuery).getQuery();
447+
447448
assertThat(parsedQuery, instanceOf(ApproximateScoreQuery.class));
448-
parsedQuery = ((ApproximateScoreQuery) parsedQuery).getApproximationQuery();
449-
assertThat(parsedQuery, instanceOf(ApproximateQuery.class));
450-
// TODO what else can we assert
449+
450+
// Get the exact query from ApproximateScoreQuery (which should be DateRangeIncludingNowQuery)
451+
ApproximateScoreQuery approximateScoreQuery = (ApproximateScoreQuery) parsedQuery;
452+
Query exactQuery = approximateScoreQuery.getOriginalQuery();
453+
454+
// The exact query should be DateRangeIncludingNowQuery
455+
assertThat(exactQuery, instanceOf(DateRangeIncludingNowQuery.class));
456+
457+
ApproximateQuery approximationQuery = approximateScoreQuery.getApproximationQuery();
458+
assertThat(approximationQuery, instanceOf(ApproximatePointRangeQuery.class));
459+
451460

452461
query = "{\n"
453462
+ " \"range\" : {\n"

0 commit comments

Comments
 (0)