You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by za...@apache.org on 2022/07/07 08:10:55 UTC
[lucene] branch main updated: LUCENE-10480: Move scoring from advance to TwoPhaseIterator#matches to improve disjunction within conjunction (#1006)
This is an automated email from the ASF dual-hosted git repository.
zacharymorn pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/lucene.git
The following commit(s) were added to refs/heads/main by this push:
new da8143bfa38 LUCENE-10480: Move scoring from advance to TwoPhaseIterator#matches to improve disjunction within conjunction (#1006)
da8143bfa38 is described below
commit da8143bfa38cd5fadae4b4712b9e639e79016021
Author: zacharymorn <za...@yahoo.com>
AuthorDate: Thu Jul 7 01:10:50 2022 -0700
LUCENE-10480: Move scoring from advance to TwoPhaseIterator#matches to improve disjunction within conjunction (#1006)
---
.../lucene/search/BlockMaxMaxscoreScorer.java | 41 +++++++++-------------
1 file changed, 17 insertions(+), 24 deletions(-)
diff --git a/lucene/core/src/java/org/apache/lucene/search/BlockMaxMaxscoreScorer.java b/lucene/core/src/java/org/apache/lucene/search/BlockMaxMaxscoreScorer.java
index d2f84062bd9..f6305e5e2b3 100644
--- a/lucene/core/src/java/org/apache/lucene/search/BlockMaxMaxscoreScorer.java
+++ b/lucene/core/src/java/org/apache/lucene/search/BlockMaxMaxscoreScorer.java
@@ -138,28 +138,7 @@ class BlockMaxMaxscoreScorer extends Scorer {
} else if (top.doc > upTo) {
target = upTo + 1;
} else {
- // Start evaluating the score of the new document. It only includes essential
- // clauses here, scores of non-essential clauses get added later on in
- // TwoPhaseIterator#matches.
- score = 0;
- for (DisiWrapper w = essentialsScorers.topList(); w != null; w = w.next) {
- score += w.scorer.score();
- }
-
- final double docScoreUpperBound = score + nonEssentialMaxScoreSum;
- if (maxScoreSumPropagator.scoreSumUpperBound(docScoreUpperBound)
- < minCompetitiveScore) {
- // skip straight to next candidate doc from essential scorer
- int docId = top.doc;
- do {
- top.doc = top.iterator.nextDoc();
- top = essentialsScorers.updateTop();
- } while (top.doc == docId);
-
- target = top.doc;
- } else {
- return doc = top.doc;
- }
+ return doc = top.doc;
}
}
}
@@ -251,8 +230,21 @@ class BlockMaxMaxscoreScorer extends Scorer {
@Override
public boolean matches() throws IOException {
- // Only sum up scores of non-essential scorers, essential scores were already folded into
- // the score.
+ // Start evaluating the score of the new document. It initially only includes essential
+ // clauses and abort / return early if a match is not possible.
+ // Scores of non-essential clauses get added later on to determine actual matches.
+ score = 0;
+ for (DisiWrapper w = essentialsScorers.topList(); w != null; w = w.next) {
+ score += w.scorer.score();
+ }
+
+ final double docScoreUpperBound = score + nonEssentialMaxScoreSum;
+
+ if (maxScoreSumPropagator.scoreSumUpperBound(docScoreUpperBound) < minCompetitiveScore) {
+ return false;
+ }
+
+ // Continue to add scores of non-essential scorers
for (int i = 0; i < firstEssentialScorerIndex; ++i) {
DisiWrapper w = allScorers[i];
if (w.doc < doc) {
@@ -262,6 +254,7 @@ class BlockMaxMaxscoreScorer extends Scorer {
score += allScorers[i].scorer.score();
}
}
+
return score() >= minCompetitiveScore;
}