Skip to content

Commit efd857e

Browse files
committed
add weight.count optimization for no match
Signed-off-by: Sandesh Kumar <[email protected]>
1 parent b0417f3 commit efd857e

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

server/src/main/java/org/opensearch/search/aggregations/bucket/composite/CompositeAggregator.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ public final class CompositeAggregator extends BucketsAggregator {
119119
private BucketCollector deferredCollectors;
120120

121121
private boolean earlyTerminated;
122+
private Weight weight;
122123

123124
private final FilterRewriteOptimizationContext filterRewriteOptimizationContext;
124125
private LongKeyedBucketOrds bucketOrds;
@@ -567,8 +568,15 @@ private void processLeafFromQuery(LeafReaderContext ctx, Sort indexSortPrefix) t
567568
}
568569
}
569570

571+
public void setWeight(Weight weight) {
572+
this.weight = weight;
573+
}
574+
570575
@Override
571576
protected boolean tryPrecomputeAggregationForLeaf(LeafReaderContext ctx) throws IOException {
577+
if (this.weight != null && this.weight.count(ctx) == 0) {
578+
return true;
579+
}
572580
finishLeaf(); // May need to wrap up previous leaf if it could not be precomputed
573581
return filterRewriteOptimizationContext.tryOptimize(
574582
ctx,

0 commit comments

Comments
 (0)