Skip to content

Commit 9a5ad11

Browse files
authored
ES|QL: Pass fixed size instead of maxPageSize to LuceneTopNOperator scorer (elastic#135767) (elastic#135866)
1 parent d2d6c08 commit 9a5ad11

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
@@ -123,6 +123,9 @@ public String describe() {
123123
}
124124
}
125125

126+
// We use the same value as the INITIAL_INTERVAL from CancellableBulkScorer
127+
private static final int NUM_DOCS_INTERVAL = 1 << 12;
128+
126129
private final CircuitBreaker breaker;
127130
private final List<SortBuilder<?>> sorts;
128131
private final long estimatedPerRowSortSize;
@@ -213,7 +216,7 @@ private Page collect() throws IOException {
213216
perShardCollector = newPerShardCollector(scorer.shardContext(), sorts, needsScore, limit);
214217
}
215218
var leafCollector = perShardCollector.getLeafCollector(scorer.leafReaderContext());
216-
scorer.scoreNextRange(leafCollector, scorer.leafReaderContext().reader().getLiveDocs(), maxPageSize);
219+
scorer.scoreNextRange(leafCollector, scorer.leafReaderContext().reader().getLiveDocs(), NUM_DOCS_INTERVAL);
217220
} catch (CollectionTerminatedException cte) {
218221
// Lucene terminated early the collection (doing topN for an index that's sorted and the topN uses the same sorting)
219222
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)