Skip to content

Commit 074bc6a

Browse files
authored
Add heuristic slice_size for slice level top buckets in concurrent segment search (opensearch-project#11585)
Signed-off-by: Jay Deng <[email protected]>
1 parent 79b1b74 commit 074bc6a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

server/src/main/java/org/opensearch/search/internal/SearchContext.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import org.apache.lucene.search.CollectorManager;
3636
import org.apache.lucene.search.FieldDoc;
3737
import org.apache.lucene.search.Query;
38-
import org.apache.lucene.util.ArrayUtil;
3938
import org.opensearch.action.search.SearchShardTask;
4039
import org.opensearch.action.search.SearchType;
4140
import org.opensearch.common.Nullable;
@@ -87,6 +86,8 @@
8786
import java.util.concurrent.CopyOnWriteArrayList;
8887
import java.util.concurrent.atomic.AtomicBoolean;
8988

89+
import static org.opensearch.search.aggregations.bucket.BucketUtils.suggestShardSideQueueSize;
90+
9091
/**
9192
* This class encapsulates the state needed to execute a search. It holds a reference to the
9293
* shards point in time snapshot (IndexReader / ContextIndexSearcher) and allows passing on
@@ -410,7 +411,7 @@ public boolean shouldUseConcurrentSearch() {
410411
*/
411412
public LocalBucketCountThresholds asLocalBucketCountThresholds(TermsAggregator.BucketCountThresholds bucketCountThresholds) {
412413
if (shouldUseConcurrentSearch()) {
413-
return new LocalBucketCountThresholds(0, ArrayUtil.MAX_ARRAY_LENGTH - 1);
414+
return new LocalBucketCountThresholds(0, suggestShardSideQueueSize(bucketCountThresholds.getShardSize()));
414415
} else {
415416
return new LocalBucketCountThresholds(bucketCountThresholds.getShardMinDocCount(), bucketCountThresholds.getShardSize());
416417
}

0 commit comments

Comments
 (0)