Skip to content

Commit

Permalink
Add heuristic slice_size for slice level top buckets in concurrent se…
Browse files Browse the repository at this point in the history
…gment search (opensearch-project#11585)

Signed-off-by: Jay Deng <[email protected]>
Signed-off-by: Shivansh Arora <[email protected]>
  • Loading branch information
jed326 authored and shiv0408 committed Apr 25, 2024
1 parent d3064d8 commit b176c77
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import org.apache.lucene.search.CollectorManager;
import org.apache.lucene.search.FieldDoc;
import org.apache.lucene.search.Query;
import org.apache.lucene.util.ArrayUtil;
import org.opensearch.action.search.SearchShardTask;
import org.opensearch.action.search.SearchType;
import org.opensearch.common.Nullable;
Expand Down Expand Up @@ -87,6 +86,8 @@
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicBoolean;

import static org.opensearch.search.aggregations.bucket.BucketUtils.suggestShardSideQueueSize;

/**
* This class encapsulates the state needed to execute a search. It holds a reference to the
* shards point in time snapshot (IndexReader / ContextIndexSearcher) and allows passing on
Expand Down Expand Up @@ -410,7 +411,7 @@ public boolean shouldUseConcurrentSearch() {
*/
public LocalBucketCountThresholds asLocalBucketCountThresholds(TermsAggregator.BucketCountThresholds bucketCountThresholds) {
if (shouldUseConcurrentSearch()) {
return new LocalBucketCountThresholds(0, ArrayUtil.MAX_ARRAY_LENGTH - 1);
return new LocalBucketCountThresholds(0, suggestShardSideQueueSize(bucketCountThresholds.getShardSize()));
} else {
return new LocalBucketCountThresholds(bucketCountThresholds.getShardMinDocCount(), bucketCountThresholds.getShardSize());
}
Expand Down

0 comments on commit b176c77

Please sign in to comment.