Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.FixedBitSet;
import org.apache.lucene.util.RamUsageEstimator;
import org.opensearch.OpenSearchStatusException;

import org.opensearch.common.Nullable;
import org.opensearch.common.hash.MurmurHash3;
import org.opensearch.common.lease.Releasable;
Expand All @@ -65,7 +65,7 @@
import org.opensearch.common.util.LongArray;
import org.opensearch.common.util.ObjectArray;
import org.opensearch.core.common.unit.ByteSizeValue;
import org.opensearch.core.rest.RestStatus;

import org.opensearch.index.fielddata.SortedBinaryDocValues;
import org.opensearch.index.fielddata.SortedNumericDoubleValues;
import org.opensearch.search.aggregations.Aggregator;
Expand Down Expand Up @@ -278,6 +278,7 @@ private boolean tryScoreWithPruningCollector(LeafReaderContext ctx, Collector pr
Weight weight = context.query().rewrite(context.searcher()).createWeight(context.searcher(), ScoreMode.TOP_DOCS, 1f);
Scorer scorer = weight.scorer(ctx);
if (scorer == null) {
Releasables.close(pruningCollector);
return false;
}
pruningCollector.setScorer(scorer);
Expand All @@ -287,13 +288,14 @@ private boolean tryScoreWithPruningCollector(LeafReaderContext ctx, Collector pr
pruningCollector.postCollect();
Releasables.close(pruningCollector);
} catch (Exception e) {
throw new OpenSearchStatusException(
"Failed when performing dynamic pruning in cardinality aggregation. You can set cluster setting ["
+ CARDINALITY_AGGREGATION_PRUNING_THRESHOLD.getKey()
+ "] to 0 to disable.",
RestStatus.INTERNAL_SERVER_ERROR,
Releasables.closeWhileHandlingException(pruningCollector);
logger.warn(
"Dynamic pruning failed for cardinality aggregation, falling back to non-pruning path. "
+ "You can set cluster setting [{}] to 0 to disable this optimization.",
CARDINALITY_AGGREGATION_PRUNING_THRESHOLD.getKey(),
e
);
return false;
}
return true;
}
Expand Down
Loading