Skip to content

Apache Lucene open-source search software

Utilize docIDRunEnd on ReqExclBulkScorer (#14976)

Samuel.G182208e84b03
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 1a23a895f0d..56974c03cd5 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -216,6 +216,8 @@ Optimizations
* GITHUB#14896: Vectorize filterCompetitiveHits (Ge Song, Adrien Grand)
+* GITHUB#14976: 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..da665c0dd95 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 = Math.min(exclApproximation.docIDRunEnd(), max);
+ } else if (exclTwoPhase.matches()) {
// upTo is excluded so we can consider that we scored up to upTo+1
upTo += 1;
}