Skip to content

Apache Lucene open-source search software

Utilize `docIdRunEnd` on `ReqExclBulkScorer` (#14806)

Samuel.G500efebc67d3
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index f37370b886b..e625456a70c 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -214,6 +214,8 @@ Optimizations
* GITHUB#14896: Vectorize filterCompetitiveHits (Ge Song, Adrien Grand)
+* GITHUB#14806: Utilize docIdRunEnd on ReqExclBulkScorer. (Ge Song)
+
Changes in Runtime Behavior
---------------------
* GITHUB#14823: Decrease TieredMergePolicy's default number of segments per
diff --git a/lucene/core/src/java/org/apache/lucene/search/ReqExclBulkScorer.java b/lucene/core/src/java/org/apache/lucene/search/ReqExclBulkScorer.java
index 7c07ef0386d..0d5c927ea14 100644
--- a/lucene/core/src/java/org/apache/lucene/search/ReqExclBulkScorer.java
+++ b/lucene/core/src/java/org/apache/lucene/search/ReqExclBulkScorer.java
@@ -57,7 +57,10 @@ final class ReqExclBulkScorer extends BulkScorer {
exclDoc = exclApproximation.advance(upTo);
}
if (exclDoc == upTo) {
- if (exclTwoPhase == null || exclTwoPhase.matches()) {
+ if (exclTwoPhase == null) {
+ // from upTo to docIdRunEnd() are excluded, so we scored up to docIdRunEnd()
+ upTo = exclApproximation.docIDRunEnd();
+ } else if (exclTwoPhase.matches()) {
// upTo is excluded so we can consider that we scored up to upTo+1
upTo += 1;
}