From e2ecd4c6862cf67be40645aea92ef1544ac8d4f7 Mon Sep 17 00:00:00 2001 From: bowenlan-amzn Date: Wed, 3 Jan 2024 15:34:39 -0800 Subject: [PATCH] Address comments Signed-off-by: bowenlan-amzn --- .../search/aggregations/bucket/FastFilterRewriteHelper.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/FastFilterRewriteHelper.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/FastFilterRewriteHelper.java index 083e4702e02f0..1d1e7a5fe7862 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/FastFilterRewriteHelper.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/FastFilterRewriteHelper.java @@ -140,6 +140,7 @@ private static Weight[] createFilterForAggregations( int bucketCount = 0; while (roundedLow <= fieldType.convertNanosToMillis(high)) { bucketCount++; + if (bucketCount > MAX_NUM_FILTER_BUCKETS) return null; // Below rounding is needed as the interval could return in // non-rounded values for something like calendar month roundedLow = preparedRounding.round(roundedLow + interval); @@ -148,7 +149,7 @@ private static Weight[] createFilterForAggregations( } Weight[] filters = null; - if (bucketCount > 0 && bucketCount <= MAX_NUM_FILTER_BUCKETS) { + if (bucketCount > 0) { filters = new Weight[bucketCount]; roundedLow = preparedRounding.round(fieldType.convertNanosToMillis(low));