From b2d2606a205d2ffe14d5634a736d5194e7e63a8c Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Fri, 17 Nov 2023 16:26:02 +0530 Subject: [PATCH] Fixing minor bugs in refactoring Signed-off-by: Ankit Jain --- .../bucket/histogram/DateHistogramAggregator.java | 6 +++--- .../aggregations/bucket/histogram/FilterRewriteHelper.java | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/histogram/DateHistogramAggregator.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/histogram/DateHistogramAggregator.java index 1200740f682d6..228b063ec1d52 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/histogram/DateHistogramAggregator.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/histogram/DateHistogramAggregator.java @@ -128,8 +128,8 @@ class DateHistogramAggregator extends BucketsAggregator implements SizedBucketAg final PointRangeQuery prq = (PointRangeQuery) cq; // Ensure that the query and aggregation are on the same field if (prq.getField().equals(fieldName)) { - FilterRewriteHelper.createFilterForAggregations( - aggregationContext, + filters = FilterRewriteHelper.createFilterForAggregations( + context, rounding, preparedRounding, fieldName, @@ -138,7 +138,7 @@ class DateHistogramAggregator extends BucketsAggregator implements SizedBucketAg ); } } else if (cq instanceof MatchAllDocsQuery) { - FilterRewriteHelper.findBoundsAndCreateFilters(context, rounding, preparedRounding, fieldName); + filters = FilterRewriteHelper.findBoundsAndCreateFilters(context, rounding, preparedRounding, fieldName); } } } diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/histogram/FilterRewriteHelper.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/histogram/FilterRewriteHelper.java index 26d2369a54817..4226bf326ec6e 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/histogram/FilterRewriteHelper.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/histogram/FilterRewriteHelper.java @@ -65,7 +65,7 @@ public static Query unwrapIntoConcreteQuery(Query query) { * Finds the min and max bounds for segments within the passed search context * and creates the weight filters using range queries within those bounds */ - public static void findBoundsAndCreateFilters( + public static Weight[] findBoundsAndCreateFilters( final SearchContext context, final Rounding rounding, final Rounding.Prepared preparedRounding, @@ -79,7 +79,8 @@ public static void findBoundsAndCreateFilters( min = Math.min(min, NumericUtils.sortableBytesToLong(leaf.reader().getPointValues(fieldName).getMinPackedValue(), 0)); max = Math.max(max, NumericUtils.sortableBytesToLong(leaf.reader().getPointValues(fieldName).getMaxPackedValue(), 0)); } - createFilterForAggregations(context, rounding, preparedRounding, fieldName, min, max); + System.out.println("Auto min and max for aggregation are : " + min + " : " + max); + return createFilterForAggregations(context, rounding, preparedRounding, fieldName, min, max); } /**