From fc7c8d41865d5a112676eadbe162a2c81b5a49c0 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Mon, 8 Sep 2025 11:48:54 -0400 Subject: [PATCH] Aggs: Fix test Make sure that data lands in both ranges so we properly emulate the non-optimized case. Closes #128471 --- .../aggregations/bucket/range/RangeAggregatorTests.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server/src/test/java/org/elasticsearch/search/aggregations/bucket/range/RangeAggregatorTests.java b/server/src/test/java/org/elasticsearch/search/aggregations/bucket/range/RangeAggregatorTests.java index 837dae1d56293..aa7e312f601af 100644 --- a/server/src/test/java/org/elasticsearch/search/aggregations/bucket/range/RangeAggregatorTests.java +++ b/server/src/test/java/org/elasticsearch/search/aggregations/bucket/range/RangeAggregatorTests.java @@ -592,11 +592,10 @@ public void testOverlappingRanges() throws IOException { /** * If the top level query is a runtime field we use the standard aggregator * because it's marginally faster. You'd expect it to be a *ton* faster but - * usually the ranges drive the iteration and they are still fairly fast. + * usually the ranges drive the iteration, and they are still fairly fast. * But the union operation overhead that comes with combining the range with * the top level query tends to slow us down more than the standard aggregator. */ - @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/128471") public void testRuntimeFieldTopLevelQueryNotOptimized() throws IOException { long totalDocs = (long) RangeAggregator.DOCS_PER_RANGE_TO_USE_FILTERS * 4; SearchLookup lookup = new SearchLookup(s -> null, (ft, l, ftd) -> null, (ctx, doc) -> null); @@ -609,7 +608,8 @@ public void execute() { Query query = new StringScriptFieldTermQuery(new Script("dummy"), scriptFactory, "dummy", "cat", false); debugTestCase(new RangeAggregationBuilder("r").field(NUMBER_FIELD_NAME).addRange(0, 1).addRange(1, 2).addRange(2, 3), query, iw -> { for (int d = 0; d < totalDocs; d++) { - iw.addDocument(List.of(new IntPoint(NUMBER_FIELD_NAME, 0), new SortedNumericDocValuesField(NUMBER_FIELD_NAME, 0))); + int v = d % 2; + iw.addDocument(List.of(new IntPoint(NUMBER_FIELD_NAME, v), new SortedNumericDocValuesField(NUMBER_FIELD_NAME, v))); } }, (InternalRange r, Class impl, Map> debug) -> { assertThat( @@ -620,7 +620,7 @@ public void execute() { assertThat(r.getBuckets().stream().map(InternalRange.Bucket::getTo).collect(toList()), equalTo(List.of(1.0, 2.0, 3.0))); assertThat( r.getBuckets().stream().map(InternalRange.Bucket::getDocCount).collect(toList()), - equalTo(List.of(totalDocs, 0L, 0L)) + equalTo(List.of(totalDocs / 2, totalDocs / 2, 0L)) ); assertThat(impl, equalTo(RangeAggregator.NoOverlap.class)); assertMap(