From 5eb320367fd5b5a479204b00f0ee55b05aaa5d63 Mon Sep 17 00:00:00 2001 From: Anthony Leong Date: Tue, 9 Dec 2025 13:18:36 -0800 Subject: [PATCH 01/11] make range method not share comparator Signed-off-by: Anthony Leong --- .../search/aggregations/bucket/filterrewrite/Ranges.java | 8 ++++---- .../rangecollector/AbstractRangeCollector.java | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/filterrewrite/Ranges.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/filterrewrite/Ranges.java index 44d94ab4a6658..7018d51284204 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/filterrewrite/Ranges.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/filterrewrite/Ranges.java @@ -18,7 +18,7 @@ public final class Ranges { byte[][] uppers; // exclusive int size; int byteLen; - static ArrayUtil.ByteArrayComparator comparator; + ArrayUtil.ByteArrayComparator comparator; Ranges(byte[][] lowers, byte[][] uppers) { this.lowers = lowers; @@ -55,15 +55,15 @@ public int firstRangeIndex(byte[] globalMin, byte[] globalMax) { return i; } - public static int compareByteValue(byte[] value1, byte[] value2) { + public int compareByteValue(byte[] value1, byte[] value2) { return comparator.compare(value1, 0, value2, 0); } - public static boolean withinLowerBound(byte[] value, byte[] lowerBound) { + public boolean withinLowerBound(byte[] value, byte[] lowerBound) { return compareByteValue(value, lowerBound) >= 0; } - public static boolean withinUpperBound(byte[] value, byte[] upperBound) { + public boolean withinUpperBound(byte[] value, byte[] upperBound) { return compareByteValue(value, upperBound) < 0; } } diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/filterrewrite/rangecollector/AbstractRangeCollector.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/filterrewrite/rangecollector/AbstractRangeCollector.java index c5f0824e2967c..92742ec6eface 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/filterrewrite/rangecollector/AbstractRangeCollector.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/filterrewrite/rangecollector/AbstractRangeCollector.java @@ -52,12 +52,12 @@ public boolean iterateRangeEnd(byte[] value, boolean inLeaf) { @Override public boolean withinLowerBound(byte[] value) { - return Ranges.withinLowerBound(value, ranges.getLowers()[activeIndex]); + return ranges.withinLowerBound(value, ranges.getLowers()[activeIndex]); } @Override public boolean withinUpperBound(byte[] value) { - return Ranges.withinUpperBound(value, ranges.getUppers()[activeIndex]); + return ranges.withinUpperBound(value, ranges.getUppers()[activeIndex]); } @Override From afea9e39422d89392cd7fb21b7c99ca9c6d7f62f Mon Sep 17 00:00:00 2001 From: Anthony Leong Date: Tue, 9 Dec 2025 21:29:09 -0800 Subject: [PATCH 02/11] try out test Signed-off-by: Anthony Leong --- .../test/search.aggregation/40_range.yml | 46 +++++++++++++++++++ .../bucket/filterrewrite/Ranges.java | 4 ++ .../AbstractRangeCollector.java | 2 + 3 files changed, 52 insertions(+) diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/40_range.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/40_range.yml index 7ecca633ce9ea..117ccffe6e5ef 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/40_range.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/40_range.yml @@ -738,3 +738,49 @@ setup: - match: { hits.total.value: 3 } - match: { aggregations.HalloweenAgg.buckets.to-october.doc_count: 3 } - match: { aggregations.HalloweenAgg.buckets.from-september.doc_count: 0 } + +--- +"Date range and range aggregation test": + - do: + indices.create: + index: test_date_range_and_range_agg + body: + settings: + number_of_replicas: 0 + number_of_shards: 1 + refresh_interval: -1 + mappings: + properties: + date_created: + type: date + distribution: + properties: + number_events: + type: unsigned_long + - do: + index: + index: test_date_range_and_range_agg + id: 1 + body: { "date_created": "2024", "distribution": { "number_events": 1000000}} + - do: + search: + index: test_date_range_and_range_agg + body: + size: 0 + aggregations: + year: + date_histogram: + field: date_created + interval: "year" + format: "yyyy" + number_events: + range: + field: distribution.number_events + ranges: + - to: 1000 + from: 0 + key: "0--999" + - to: 10000000000000 + from: 1000 + key: "999--" + _source: false diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/filterrewrite/Ranges.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/filterrewrite/Ranges.java index 7018d51284204..c3a66c974141e 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/filterrewrite/Ranges.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/filterrewrite/Ranges.java @@ -18,6 +18,7 @@ public final class Ranges { byte[][] uppers; // exclusive int size; int byteLen; + //static ArrayUtil.ByteArrayComparator comparator; ArrayUtil.ByteArrayComparator comparator; Ranges(byte[][] lowers, byte[][] uppers) { @@ -55,14 +56,17 @@ public int firstRangeIndex(byte[] globalMin, byte[] globalMax) { return i; } + //public static int compareByteValue(byte[] value1, byte[] value2) { public int compareByteValue(byte[] value1, byte[] value2) { return comparator.compare(value1, 0, value2, 0); } + //public static boolean withinLowerBound(byte[] value, byte[] lowerBound) { public boolean withinLowerBound(byte[] value, byte[] lowerBound) { return compareByteValue(value, lowerBound) >= 0; } + //public static boolean withinUpperBound(byte[] value, byte[] upperBound) { public boolean withinUpperBound(byte[] value, byte[] upperBound) { return compareByteValue(value, upperBound) < 0; } diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/filterrewrite/rangecollector/AbstractRangeCollector.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/filterrewrite/rangecollector/AbstractRangeCollector.java index 92742ec6eface..933ffebb92060 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/filterrewrite/rangecollector/AbstractRangeCollector.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/filterrewrite/rangecollector/AbstractRangeCollector.java @@ -52,11 +52,13 @@ public boolean iterateRangeEnd(byte[] value, boolean inLeaf) { @Override public boolean withinLowerBound(byte[] value) { + //return Ranges.withinLowerBound(value, ranges.getLowers()[activeIndex]); return ranges.withinLowerBound(value, ranges.getLowers()[activeIndex]); } @Override public boolean withinUpperBound(byte[] value) { + //return Ranges.withinLowerBound(value, ranges.getLowers()[activeIndex]); return ranges.withinUpperBound(value, ranges.getUppers()[activeIndex]); } From 789555224c5899fec1101f9b064a00dff4cc72c6 Mon Sep 17 00:00:00 2001 From: Anthony Leong Date: Tue, 9 Dec 2025 21:29:54 -0800 Subject: [PATCH 03/11] try out test Signed-off-by: Anthony Leong --- .../bucket/filterrewrite/Ranges.java | 16 ++++++++-------- .../rangecollector/AbstractRangeCollector.java | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/filterrewrite/Ranges.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/filterrewrite/Ranges.java index c3a66c974141e..c5120ece2fdfb 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/filterrewrite/Ranges.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/filterrewrite/Ranges.java @@ -18,8 +18,8 @@ public final class Ranges { byte[][] uppers; // exclusive int size; int byteLen; - //static ArrayUtil.ByteArrayComparator comparator; - ArrayUtil.ByteArrayComparator comparator; + static ArrayUtil.ByteArrayComparator comparator; + //ArrayUtil.ByteArrayComparator comparator; Ranges(byte[][] lowers, byte[][] uppers) { this.lowers = lowers; @@ -56,18 +56,18 @@ public int firstRangeIndex(byte[] globalMin, byte[] globalMax) { return i; } - //public static int compareByteValue(byte[] value1, byte[] value2) { - public int compareByteValue(byte[] value1, byte[] value2) { + public static int compareByteValue(byte[] value1, byte[] value2) { + //public int compareByteValue(byte[] value1, byte[] value2) { return comparator.compare(value1, 0, value2, 0); } - //public static boolean withinLowerBound(byte[] value, byte[] lowerBound) { - public boolean withinLowerBound(byte[] value, byte[] lowerBound) { + public static boolean withinLowerBound(byte[] value, byte[] lowerBound) { + //public boolean withinLowerBound(byte[] value, byte[] lowerBound) { return compareByteValue(value, lowerBound) >= 0; } - //public static boolean withinUpperBound(byte[] value, byte[] upperBound) { - public boolean withinUpperBound(byte[] value, byte[] upperBound) { + public static boolean withinUpperBound(byte[] value, byte[] upperBound) { + //public boolean withinUpperBound(byte[] value, byte[] upperBound) { return compareByteValue(value, upperBound) < 0; } } diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/filterrewrite/rangecollector/AbstractRangeCollector.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/filterrewrite/rangecollector/AbstractRangeCollector.java index 933ffebb92060..ee94c05cd1c26 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/filterrewrite/rangecollector/AbstractRangeCollector.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/filterrewrite/rangecollector/AbstractRangeCollector.java @@ -52,14 +52,14 @@ public boolean iterateRangeEnd(byte[] value, boolean inLeaf) { @Override public boolean withinLowerBound(byte[] value) { - //return Ranges.withinLowerBound(value, ranges.getLowers()[activeIndex]); - return ranges.withinLowerBound(value, ranges.getLowers()[activeIndex]); + return Ranges.withinLowerBound(value, ranges.getLowers()[activeIndex]); + //return ranges.withinLowerBound(value, ranges.getLowers()[activeIndex]); } @Override public boolean withinUpperBound(byte[] value) { - //return Ranges.withinLowerBound(value, ranges.getLowers()[activeIndex]); - return ranges.withinUpperBound(value, ranges.getUppers()[activeIndex]); + return Ranges.withinLowerBound(value, ranges.getLowers()[activeIndex]); + //return ranges.withinUpperBound(value, ranges.getUppers()[activeIndex]); } @Override From 3b8467c4720e924b9708e37a5a3340a434a9f73a Mon Sep 17 00:00:00 2001 From: Anthony Leong Date: Tue, 9 Dec 2025 21:58:13 -0800 Subject: [PATCH 04/11] spotless Signed-off-by: Anthony Leong --- .../search/aggregations/bucket/filterrewrite/Ranges.java | 8 ++++---- .../rangecollector/AbstractRangeCollector.java | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/filterrewrite/Ranges.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/filterrewrite/Ranges.java index c5120ece2fdfb..8ca0c9e17c8f1 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/filterrewrite/Ranges.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/filterrewrite/Ranges.java @@ -19,7 +19,7 @@ public final class Ranges { int size; int byteLen; static ArrayUtil.ByteArrayComparator comparator; - //ArrayUtil.ByteArrayComparator comparator; + // ArrayUtil.ByteArrayComparator comparator; Ranges(byte[][] lowers, byte[][] uppers) { this.lowers = lowers; @@ -57,17 +57,17 @@ public int firstRangeIndex(byte[] globalMin, byte[] globalMax) { } public static int compareByteValue(byte[] value1, byte[] value2) { - //public int compareByteValue(byte[] value1, byte[] value2) { + // public int compareByteValue(byte[] value1, byte[] value2) { return comparator.compare(value1, 0, value2, 0); } public static boolean withinLowerBound(byte[] value, byte[] lowerBound) { - //public boolean withinLowerBound(byte[] value, byte[] lowerBound) { + // public boolean withinLowerBound(byte[] value, byte[] lowerBound) { return compareByteValue(value, lowerBound) >= 0; } public static boolean withinUpperBound(byte[] value, byte[] upperBound) { - //public boolean withinUpperBound(byte[] value, byte[] upperBound) { + // public boolean withinUpperBound(byte[] value, byte[] upperBound) { return compareByteValue(value, upperBound) < 0; } } diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/filterrewrite/rangecollector/AbstractRangeCollector.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/filterrewrite/rangecollector/AbstractRangeCollector.java index ee94c05cd1c26..b9b24d8d1a2ce 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/filterrewrite/rangecollector/AbstractRangeCollector.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/filterrewrite/rangecollector/AbstractRangeCollector.java @@ -53,13 +53,13 @@ public boolean iterateRangeEnd(byte[] value, boolean inLeaf) { @Override public boolean withinLowerBound(byte[] value) { return Ranges.withinLowerBound(value, ranges.getLowers()[activeIndex]); - //return ranges.withinLowerBound(value, ranges.getLowers()[activeIndex]); + // return ranges.withinLowerBound(value, ranges.getLowers()[activeIndex]); } @Override public boolean withinUpperBound(byte[] value) { return Ranges.withinLowerBound(value, ranges.getLowers()[activeIndex]); - //return ranges.withinUpperBound(value, ranges.getUppers()[activeIndex]); + // return ranges.withinUpperBound(value, ranges.getUppers()[activeIndex]); } @Override From a2090dd1a294360087cb4398c7f09546170e4ec7 Mon Sep 17 00:00:00 2001 From: Anthony Leong Date: Wed, 10 Dec 2025 13:40:28 -0800 Subject: [PATCH 05/11] changelog and apply changes Signed-off-by: Anthony Leong --- CHANGELOG.md | 1 + .../aggregations/bucket/filterrewrite/Ranges.java | 12 ++++-------- .../rangecollector/AbstractRangeCollector.java | 6 ++---- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 99a645553a46b..e3a988a62acf4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -105,6 +105,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Fixed handling of property index in BulkRequest during deserialization ([#20132](https://github.com/opensearch-project/OpenSearch/pull/20132)) - Fix negative CPU usage values in node stats ([#19120](https://github.com/opensearch-project/OpenSearch/issues/19120)) - Fix duplicate registration of FieldDataCache dynamic setting ([20140](https://github.com/opensearch-project/OpenSearch/pull/20140)) +- Fix array out of bounds during aggregation ([#20204](https://github.com/opensearch-project/OpenSearch/pull/20204)) ### Dependencies - Bump Apache Lucene from 10.3.1 to 10.3.2 ([#20026](https://github.com/opensearch-project/OpenSearch/pull/20026)) diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/filterrewrite/Ranges.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/filterrewrite/Ranges.java index 8ca0c9e17c8f1..7018d51284204 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/filterrewrite/Ranges.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/filterrewrite/Ranges.java @@ -18,8 +18,7 @@ public final class Ranges { byte[][] uppers; // exclusive int size; int byteLen; - static ArrayUtil.ByteArrayComparator comparator; - // ArrayUtil.ByteArrayComparator comparator; + ArrayUtil.ByteArrayComparator comparator; Ranges(byte[][] lowers, byte[][] uppers) { this.lowers = lowers; @@ -56,18 +55,15 @@ public int firstRangeIndex(byte[] globalMin, byte[] globalMax) { return i; } - public static int compareByteValue(byte[] value1, byte[] value2) { - // public int compareByteValue(byte[] value1, byte[] value2) { + public int compareByteValue(byte[] value1, byte[] value2) { return comparator.compare(value1, 0, value2, 0); } - public static boolean withinLowerBound(byte[] value, byte[] lowerBound) { - // public boolean withinLowerBound(byte[] value, byte[] lowerBound) { + public boolean withinLowerBound(byte[] value, byte[] lowerBound) { return compareByteValue(value, lowerBound) >= 0; } - public static boolean withinUpperBound(byte[] value, byte[] upperBound) { - // public boolean withinUpperBound(byte[] value, byte[] upperBound) { + public boolean withinUpperBound(byte[] value, byte[] upperBound) { return compareByteValue(value, upperBound) < 0; } } diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/filterrewrite/rangecollector/AbstractRangeCollector.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/filterrewrite/rangecollector/AbstractRangeCollector.java index b9b24d8d1a2ce..92742ec6eface 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/filterrewrite/rangecollector/AbstractRangeCollector.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/filterrewrite/rangecollector/AbstractRangeCollector.java @@ -52,14 +52,12 @@ public boolean iterateRangeEnd(byte[] value, boolean inLeaf) { @Override public boolean withinLowerBound(byte[] value) { - return Ranges.withinLowerBound(value, ranges.getLowers()[activeIndex]); - // return ranges.withinLowerBound(value, ranges.getLowers()[activeIndex]); + return ranges.withinLowerBound(value, ranges.getLowers()[activeIndex]); } @Override public boolean withinUpperBound(byte[] value) { - return Ranges.withinLowerBound(value, ranges.getLowers()[activeIndex]); - // return ranges.withinUpperBound(value, ranges.getUppers()[activeIndex]); + return ranges.withinUpperBound(value, ranges.getUppers()[activeIndex]); } @Override From 1a4cc6da253a65268e96f457ed070a0d0e9a7db8 Mon Sep 17 00:00:00 2001 From: Anthony Leong Date: Wed, 10 Dec 2025 16:42:46 -0800 Subject: [PATCH 06/11] add new tests Signed-off-by: Anthony Leong --- .../java/org/opensearch/client/SearchIT.java | 61 +++++++++++++++++++ .../test/search.aggregation/40_range.yml | 46 -------------- 2 files changed, 61 insertions(+), 46 deletions(-) diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/SearchIT.java b/client/rest-high-level/src/test/java/org/opensearch/client/SearchIT.java index 974aa7fcc990c..87cb566622e31 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/SearchIT.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/SearchIT.java @@ -84,6 +84,9 @@ import org.opensearch.search.aggregations.bucket.composite.CompositeAggregation; import org.opensearch.search.aggregations.bucket.composite.CompositeValuesSourceBuilder; import org.opensearch.search.aggregations.bucket.composite.TermsValuesSourceBuilder; +import org.opensearch.search.aggregations.bucket.histogram.DateHistogramAggregationBuilder; +import org.opensearch.search.aggregations.bucket.histogram.DateHistogramInterval; +import org.opensearch.search.aggregations.bucket.histogram.ParsedDateHistogram; import org.opensearch.search.aggregations.bucket.range.Range; import org.opensearch.search.aggregations.bucket.range.RangeAggregationBuilder; import org.opensearch.search.aggregations.bucket.terms.MultiTermsAggregationBuilder; @@ -237,6 +240,32 @@ public void indexDocuments() throws IOException { client().performRequest(createFilteredAlias); } + { + Request create = new Request(HttpPut.METHOD_NAME, "/index5"); + create.setJsonEntity( + "{" + + " \"mappings\": {" + + " \"properties\": {" + + " \"date_created\": {" + + " \"type\": \"date\"" + + " }," + + " \"distribution\": {" + + " \"properties\": {" + + " \"number_events\": {" + + " \"type\": \"unsigned_long\"" + + " }" + + " }" + + " }" + + " }" + + " }" + + "}" + ); + client().performRequest(create); + Request doc1 = new Request(HttpPut.METHOD_NAME, "/index5/_doc/1"); + doc1.setJsonEntity("{\"date_created\":\"2024\", \"distribution\":{\"number_events\": 1000000}}"); + client().performRequest(doc1); + } + client().performRequest(new Request(HttpPost.METHOD_NAME, "/_refresh")); } @@ -514,6 +543,38 @@ public void testSearchWithTermsAndRangeAgg() throws IOException { } } + public void testSearchWithDateAndRangeAgg() throws IOException { + SearchRequest searchRequest = new SearchRequest("index5"); + SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); + DateHistogramAggregationBuilder yearAgg = new DateHistogramAggregationBuilder("year").field("date_created") + .calendarInterval(DateHistogramInterval.YEAR) + .format("yyyy"); + + RangeAggregationBuilder rangeAgg = new RangeAggregationBuilder("number_events").field("distribution.number_events") + .addRange("0--999", 0.0, 1000.0) + .addRange("999--", 1000.0, 10_000_000_000_00L); + searchSourceBuilder.aggregation(yearAgg).aggregation(rangeAgg); + searchSourceBuilder.size(0); + searchRequest.source(searchSourceBuilder); + SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync); + assertSearchHeader(searchResponse); + ParsedDateHistogram yearHistogram = searchResponse.getAggregations().get("year"); + assertEquals(1, yearHistogram.getBuckets().size()); + assertEquals("2024", yearHistogram.getBuckets().get(0).getKeyAsString()); + Range rangeAggregation = searchResponse.getAggregations().get("number_events"); + assertEquals(2, rangeAggregation.getBuckets().size()); + { + Range.Bucket bucket = rangeAggregation.getBuckets().get(0); + assertEquals("0--999", bucket.getKeyAsString()); + assertEquals(0, bucket.getDocCount()); + } + { + Range.Bucket bucket = rangeAggregation.getBuckets().get(1); + assertEquals("999--", bucket.getKeyAsString()); + assertEquals(1, bucket.getDocCount()); + } + } + public void testSearchWithTermsAndWeightedAvg() throws IOException { SearchRequest searchRequest = new SearchRequest("index"); SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/40_range.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/40_range.yml index 117ccffe6e5ef..7ecca633ce9ea 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/40_range.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/40_range.yml @@ -738,49 +738,3 @@ setup: - match: { hits.total.value: 3 } - match: { aggregations.HalloweenAgg.buckets.to-october.doc_count: 3 } - match: { aggregations.HalloweenAgg.buckets.from-september.doc_count: 0 } - ---- -"Date range and range aggregation test": - - do: - indices.create: - index: test_date_range_and_range_agg - body: - settings: - number_of_replicas: 0 - number_of_shards: 1 - refresh_interval: -1 - mappings: - properties: - date_created: - type: date - distribution: - properties: - number_events: - type: unsigned_long - - do: - index: - index: test_date_range_and_range_agg - id: 1 - body: { "date_created": "2024", "distribution": { "number_events": 1000000}} - - do: - search: - index: test_date_range_and_range_agg - body: - size: 0 - aggregations: - year: - date_histogram: - field: date_created - interval: "year" - format: "yyyy" - number_events: - range: - field: distribution.number_events - ranges: - - to: 1000 - from: 0 - key: "0--999" - - to: 10000000000000 - from: 1000 - key: "999--" - _source: false From 822b8678a06d3b6033e9b7c84be1679b833bdab7 Mon Sep 17 00:00:00 2001 From: Anthony Leong Date: Wed, 10 Dec 2025 19:07:04 -0800 Subject: [PATCH 07/11] update indices count test Signed-off-by: Anthony Leong --- .../src/test/java/org/opensearch/client/SearchIT.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/SearchIT.java b/client/rest-high-level/src/test/java/org/opensearch/client/SearchIT.java index 87cb566622e31..e2287eb53db60 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/SearchIT.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/SearchIT.java @@ -1847,7 +1847,7 @@ public void testCountAllIndicesNoQuery() throws IOException { CountRequest countRequest = new CountRequest(); CountResponse countResponse = execute(countRequest, highLevelClient()::count, highLevelClient()::countAsync); assertCountHeader(countResponse); - assertEquals(12, countResponse.getCount()); + assertEquals(13, countResponse.getCount()); } public void testCountOneIndexMatchQuery() throws IOException { From 9fed63d9233ee60311d65f2e4e74951662ea3ac1 Mon Sep 17 00:00:00 2001 From: Anthony Leong Date: Wed, 10 Dec 2025 20:57:06 -0800 Subject: [PATCH 08/11] move changelog entry to release notes Signed-off-by: Anthony Leong --- CHANGELOG.md | 22 ------------------- .../opensearch.release-notes-3.4.0.md | 1 + 2 files changed, 1 insertion(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 62b8b486c7a82..19ede3674f0be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,28 +13,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Fixed - Fix flaky test ClusterMaxMergesAtOnceIT.testClusterLevelDefaultUpdatesMergePolicy ([#18056](https://github.com/opensearch-project/OpenSearch/issues/18056)) -- Fix issue with updating core with a patch number other than 0 ([#19377](https://github.com/opensearch-project/OpenSearch/pull/19377)) -- [Java Agent] Allow JRT protocol URLs in protection domain extraction ([#19683](https://github.com/opensearch-project/OpenSearch/pull/19683)) -- Fix potential concurrent modification exception when updating allocation filters ([#19701])(https://github.com/opensearch-project/OpenSearch/pull/19701)) -- Fix wildcard query with escaped backslash followed by wildcard character ([#19719](https://github.com/opensearch-project/OpenSearch/pull/19719)) -- Fix file-based ingestion consumer to handle start point beyond max line number([#19757])(https://github.com/opensearch-project/OpenSearch/pull/19757)) -- Fix IndexOutOfBoundsException when running include/exclude on non-existent prefix in terms aggregations ([#19637](https://github.com/opensearch-project/OpenSearch/pull/19637)) -- Fixed assertion unsafe use of ClusterService.state() in ResourceUsageCollectorService ([#19775])(https://github.com/opensearch-project/OpenSearch/pull/19775)) -- Fix Unified highlighter for nested fields when using matchPhrasePrefixQuery ([#19442](https://github.com/opensearch-project/OpenSearch/pull/19442)) -- Add S3Repository.LEGACY_MD5_CHECKSUM_CALCULATION to list of repository-s3 settings ([#19788](https://github.com/opensearch-project/OpenSearch/pull/19788)) -- Fix NullPointerException when restoring remote snapshot with missing shard size information ([#19684](https://github.com/opensearch-project/OpenSearch/pull/19684)) -- Fix NPE of ScriptScoreQuery ([#19650](https://github.com/opensearch-project/OpenSearch/pull/19650)) -- Fix ClassCastException in FlightClientChannel for requests larger than 16KB ([#20010](https://github.com/opensearch-project/OpenSearch/pull/20010)) -- Fix GRPC Bulk ([#19937](https://github.com/opensearch-project/OpenSearch/pull/19937)) -- Fix node bootstrap error when enable stream transport and remote cluster state ([#19948](https://github.com/opensearch-project/OpenSearch/pull/19948)) -- Keep track and release Reactor Netty 4 Transport accepted Http Channels during the Node shutdown ([#20106](https://github.com/opensearch-project/OpenSearch/pull/20106)) -- Fix deletion failure/error of unused index template; case when an index template matches a data stream but has a lower priority. ([#20102](https://github.com/opensearch-project/OpenSearch/pull/20102)) -- Fixed version incompatibility in remote state entities using bytestream for ser/de ([#20080](https://github.com/opensearch-project/OpenSearch/pull/20080)) -- Fix toBuilder method in EngineConfig to include mergedSegmentTransferTracker([#20105](https://github.com/opensearch-project/OpenSearch/pull/20105)) -- Fixed handling of property index in BulkRequest during deserialization ([#20132](https://github.com/opensearch-project/OpenSearch/pull/20132)) -- Fix negative CPU usage values in node stats ([#19120](https://github.com/opensearch-project/OpenSearch/issues/19120)) -- Fix duplicate registration of FieldDataCache dynamic setting ([20140](https://github.com/opensearch-project/OpenSearch/pull/20140)) -- Fix array out of bounds during aggregation ([#20204](https://github.com/opensearch-project/OpenSearch/pull/20204)) - Fix bug in Assertion framework(Yaml Rest test): numeric comparison fails when comparing Integer vs Long (or Float vs Double) ([#19376](https://github.com/opensearch-project/OpenSearch/pull/19376)) ### Dependencies diff --git a/release-notes/opensearch.release-notes-3.4.0.md b/release-notes/opensearch.release-notes-3.4.0.md index 7cabfed577988..40b282b544b23 100644 --- a/release-notes/opensearch.release-notes-3.4.0.md +++ b/release-notes/opensearch.release-notes-3.4.0.md @@ -102,6 +102,7 @@ Compatible with OpenSearch and OpenSearch Dashboards version 3.4.0 - Fixed handling of property index in BulkRequest during deserialization ([#20132](https://github.com/opensearch-project/OpenSearch/pull/20132)) - Fix negative CPU usage values in node stats ([#19120](https://github.com/opensearch-project/OpenSearch/issues/19120)) - Fix duplicate registration of FieldDataCache dynamic setting ([#20140](https://github.com/opensearch-project/OpenSearch/pull/20140)) +- Fix array out of bounds during aggregation ([#20204](https://github.com/opensearch-project/OpenSearch/pull/20204)) ### Dependencies - Bump Apache Lucene from 10.3.1 to 10.3.2 ([#20026](https://github.com/opensearch-project/OpenSearch/pull/20026)) From 49d2d6e63fb515f2689fa7f1e1c8eed7970d6805 Mon Sep 17 00:00:00 2001 From: Anthony Leong Date: Thu, 11 Dec 2025 12:04:49 -0800 Subject: [PATCH 09/11] retry Signed-off-by: Anthony Leong From f569f9114ea23050ae5395b9a70eb7003b5f53dd Mon Sep 17 00:00:00 2001 From: Sandesh Kumar Date: Thu, 11 Dec 2025 12:37:27 -0800 Subject: [PATCH 10/11] Release notes unrelated formatting fixes Signed-off-by: Sandesh Kumar --- release-notes/opensearch.release-notes-3.4.0.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/release-notes/opensearch.release-notes-3.4.0.md b/release-notes/opensearch.release-notes-3.4.0.md index 40b282b544b23..222c61e491dad 100644 --- a/release-notes/opensearch.release-notes-3.4.0.md +++ b/release-notes/opensearch.release-notes-3.4.0.md @@ -6,11 +6,11 @@ Compatible with OpenSearch and OpenSearch Dashboards version 3.4.0 - Allow setting index.creation_date on index creation and restore for plugin compatibility and migrations ([#19931](https://github.com/opensearch-project/OpenSearch/pull/19931)) - Add support for a ForkJoinPool type ([#19008](https://github.com/opensearch-project/OpenSearch/pull/19008)) - Add seperate shard limit validation for local and remote indices ([#19532](https://github.com/opensearch-project/OpenSearch/pull/19532)) -- Use Lucene `pack` method for `half_float` and `usigned_long` when using `ApproximatePointRangeQuery`. +- Use Lucene `pack` method for `half_float` and `usigned_long` when using `ApproximatePointRangeQuery` ([#19553](https://github.com/opensearch-project/OpenSearch/pull/19553)) - New cluster setting search.query.max_query_string_length_monitor_only ([#19539](https://github.com/opensearch-project/OpenSearch/pull/19539)) - Add a mapper for context aware segments grouping criteria ([#19233](https://github.com/opensearch-project/OpenSearch/pull/19233)) - Return full error for GRPC error response ([#19568](https://github.com/opensearch-project/OpenSearch/pull/19568)) -- Add support for repository with Server side encryption enabled and client side encryption as well based on a flag. ([#19630](https://github.com/opensearch-project/OpenSearch/pull/19630)) +- Add support for repository with Server side encryption enabled and client side encryption as well based on a flag ([#19630](https://github.com/opensearch-project/OpenSearch/pull/19630)) - Add pluggable gRPC interceptors with explicit ordering([#19005](https://github.com/opensearch-project/OpenSearch/pull/19005)) - Add BindableServices extension point to transport-grpc-spi ([#19304](https://github.com/opensearch-project/OpenSearch/pull/19304)) - Add metrics for the merged segment warmer feature ([#18929](https://github.com/opensearch-project/OpenSearch/pull/18929)) @@ -19,7 +19,7 @@ Compatible with OpenSearch and OpenSearch Dashboards version 3.4.0 - Allow collectors take advantage of preaggregated data using collectRange API ([#20009](https://github.com/opensearch-project/OpenSearch/pull/20009)) - Bulk collection logic for metrics and cardinality aggregations ([#20067](https://github.com/opensearch-project/OpenSearch/pull/20067)) - Add pointer based lag metric in pull-based ingestion ([#19635](https://github.com/opensearch-project/OpenSearch/pull/19635)) -- Introduced internal API for retrieving metadata about requested indices from transport actions ([#18523](https://github.com/opensearch-project/OpenSearch/pull/18523)) +- Introduced internal API for retrieving metadata about requested indices from transport actions ([#18523](https://github.com/opensearch-project/OpenSearch/pull/18523)) - Add cluster defaults for merge autoThrottle, maxMergeThreads, and maxMergeCount; Add segment size filter to the merged segment warmer ([#19629](https://github.com/opensearch-project/OpenSearch/pull/19629)) - Add build-tooling to run in FIPS environment ([#18921](https://github.com/opensearch-project/OpenSearch/pull/18921)) - Add SMILE/CBOR/YAML document format support to Bulk GRPC endpoint ([#19744](https://github.com/opensearch-project/OpenSearch/pull/19744)) @@ -83,9 +83,9 @@ Compatible with OpenSearch and OpenSearch Dashboards version 3.4.0 - Fix pull-based ingestion out-of-bounds offset scenarios and remove persisted offsets ([#19607](https://github.com/opensearch-project/OpenSearch/pull/19607)) - Fix issue with updating core with a patch number other than 0 ([#19377](https://github.com/opensearch-project/OpenSearch/pull/19377)) - [Java Agent] Allow JRT protocol URLs in protection domain extraction ([#19683](https://github.com/opensearch-project/OpenSearch/pull/19683)) -- Fix potential concurrent modification exception when updating allocation filters ([#19701])(https://github.com/opensearch-project/OpenSearch/pull/19701)) +- Fix potential concurrent modification exception when updating allocation filters ([#19701](https://github.com/opensearch-project/OpenSearch/pull/19701)) - Fix wildcard query with escaped backslash followed by wildcard character ([#19719](https://github.com/opensearch-project/OpenSearch/pull/19719)) -- Fix file-based ingestion consumer to handle start point beyond max line number([#19757])(https://github.com/opensearch-project/OpenSearch/pull/19757)) +- Fix file-based ingestion consumer to handle start point beyond max line number([#19757](https://github.com/opensearch-project/OpenSearch/pull/19757)) - Fix IndexOutOfBoundsException when running include/exclude on non-existent prefix in terms aggregations ([#19637](https://github.com/opensearch-project/OpenSearch/pull/19637)) - Fixed assertion unsafe use of ClusterService.state() in ResourceUsageCollectorService ([#19775](https://github.com/opensearch-project/OpenSearch/pull/19775)) - Fix Unified highlighter for nested fields when using matchPhrasePrefixQuery ([#19442](https://github.com/opensearch-project/OpenSearch/pull/19442)) @@ -132,7 +132,7 @@ Compatible with OpenSearch and OpenSearch Dashboards version 3.4.0 - Bump `netty` to 4.2.4 ([#19178](https://github.com/opensearch-project/OpenSearch/pull/19178)) - Bump `actions/github-script` from 7 to 8 ([#19946](https://github.com/opensearch-project/OpenSearch/pull/19946)) - Bump `com.google.api:gax-httpjson` from 2.69.0 to 2.72.1 ([#19943](https://github.com/opensearch-project/OpenSearch/pull/19943)) -- Update Hadoop to 3.4.2 and enable security (Kerberos) integration tests under JDK-24 and above ([#19952](https://github.com/opensearch-project/OpenSearch/pull/19952)) +- Update Hadoop to 3.4.2 and enable security (Kerberos) integration tests under JDK-24 and above ([#19952](https://github.com/opensearch-project/OpenSearch/pull/19952)) - Bump `com.google.cloud:google-cloud-storage` from 2.55.0 to 2.60.0 ([#20023](https://github.com/opensearch-project/OpenSearch/pull/20023)) - Bump `commons-cli:commons-cli` from 1.10.0 to 1.11.0 ([#20022](https://github.com/opensearch-project/OpenSearch/pull/20022)) - Bump `com.squareup.okio:okio` from 3.16.0 to 3.16.3 ([#20025](https://github.com/opensearch-project/OpenSearch/pull/20025)) From d90d6a9e9000fe5531ab83c4d8e3e8a56c736c05 Mon Sep 17 00:00:00 2001 From: Sandesh Kumar Date: Thu, 11 Dec 2025 12:42:17 -0800 Subject: [PATCH 11/11] typo fix Signed-off-by: Sandesh Kumar --- release-notes/opensearch.release-notes-3.4.0.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/release-notes/opensearch.release-notes-3.4.0.md b/release-notes/opensearch.release-notes-3.4.0.md index 222c61e491dad..627f97d74fb16 100644 --- a/release-notes/opensearch.release-notes-3.4.0.md +++ b/release-notes/opensearch.release-notes-3.4.0.md @@ -6,7 +6,7 @@ Compatible with OpenSearch and OpenSearch Dashboards version 3.4.0 - Allow setting index.creation_date on index creation and restore for plugin compatibility and migrations ([#19931](https://github.com/opensearch-project/OpenSearch/pull/19931)) - Add support for a ForkJoinPool type ([#19008](https://github.com/opensearch-project/OpenSearch/pull/19008)) - Add seperate shard limit validation for local and remote indices ([#19532](https://github.com/opensearch-project/OpenSearch/pull/19532)) -- Use Lucene `pack` method for `half_float` and `usigned_long` when using `ApproximatePointRangeQuery` ([#19553](https://github.com/opensearch-project/OpenSearch/pull/19553)) +- Use Lucene `pack` method for `half_float` and `unsigned_long` when using `ApproximatePointRangeQuery` ([#19553](https://github.com/opensearch-project/OpenSearch/pull/19553)) - New cluster setting search.query.max_query_string_length_monitor_only ([#19539](https://github.com/opensearch-project/OpenSearch/pull/19539)) - Add a mapper for context aware segments grouping criteria ([#19233](https://github.com/opensearch-project/OpenSearch/pull/19233)) - Return full error for GRPC error response ([#19568](https://github.com/opensearch-project/OpenSearch/pull/19568)) @@ -85,7 +85,7 @@ Compatible with OpenSearch and OpenSearch Dashboards version 3.4.0 - [Java Agent] Allow JRT protocol URLs in protection domain extraction ([#19683](https://github.com/opensearch-project/OpenSearch/pull/19683)) - Fix potential concurrent modification exception when updating allocation filters ([#19701](https://github.com/opensearch-project/OpenSearch/pull/19701)) - Fix wildcard query with escaped backslash followed by wildcard character ([#19719](https://github.com/opensearch-project/OpenSearch/pull/19719)) -- Fix file-based ingestion consumer to handle start point beyond max line number([#19757](https://github.com/opensearch-project/OpenSearch/pull/19757)) +- Fix file-based ingestion consumer to handle start point beyond max line number ([#19757](https://github.com/opensearch-project/OpenSearch/pull/19757)) - Fix IndexOutOfBoundsException when running include/exclude on non-existent prefix in terms aggregations ([#19637](https://github.com/opensearch-project/OpenSearch/pull/19637)) - Fixed assertion unsafe use of ClusterService.state() in ResourceUsageCollectorService ([#19775](https://github.com/opensearch-project/OpenSearch/pull/19775)) - Fix Unified highlighter for nested fields when using matchPhrasePrefixQuery ([#19442](https://github.com/opensearch-project/OpenSearch/pull/19442))