Skip to content

Commit 9881d4a

Browse files
authored
ES|QL: Pass fixed size instead of maxPageSize to LuceneTopNOperator scorer (#135767) (#136156)
1 parent 7756498 commit 9881d4a

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

docs/changelog/135767.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 135767
2+
summary: Pass fix size instead of `maxPageSize` to `LuceneTopNOperator` scorer
3+
area: ES|QL
4+
type: bug
5+
issues: []

x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/lucene/LuceneTopNSourceOperator.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ public String describe() {
119119
}
120120
}
121121

122+
// We use the same value as the INITIAL_INTERVAL from CancellableBulkScorer
123+
private static final int NUM_DOCS_INTERVAL = 1 << 12;
124+
122125
private final CircuitBreaker breaker;
123126
private final List<SortBuilder<?>> sorts;
124127
private final long estimatedPerRowSortSize;
@@ -202,7 +205,7 @@ private Page collect() throws IOException {
202205
perShardCollector = newPerShardCollector(scorer.shardContext(), sorts, needsScore, limit);
203206
}
204207
var leafCollector = perShardCollector.getLeafCollector(scorer.leafReaderContext());
205-
scorer.scoreNextRange(leafCollector, scorer.leafReaderContext().reader().getLiveDocs(), maxPageSize);
208+
scorer.scoreNextRange(leafCollector, scorer.leafReaderContext().reader().getLiveDocs(), NUM_DOCS_INTERVAL);
206209
} catch (CollectionTerminatedException cte) {
207210
// Lucene terminated early the collection (doing topN for an index that's sorted and the topN uses the same sorting)
208211
scorer.markAsDone();

x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/EsqlActionTaskIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ public void testTaskContentsForTopNQuery() throws Exception {
511511
try {
512512
getTasksStarting();
513513
logger.info("unblocking script");
514-
scriptPermits.release(pageSize());
514+
scriptPermits.release(numberOfDocs() + pageSize());
515515
List<TaskInfo> tasks = getTasksRunning();
516516
String sortStatus = """
517517
[{"pause_me":{"order":"asc","missing":"_last","unmapped_type":"long"}}]""";

0 commit comments

Comments
 (0)