jpountz commented on code in PR #1006:
URL: https://github.com/apache/lucene/pull/1006#discussion_r914495821


##########
lucene/core/src/java/org/apache/lucene/search/BlockMaxMaxscoreScorer.java:
##########
@@ -251,8 +230,31 @@ public long cost() {
 
       @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.
+        DisiWrapper top = essentialsScorers.top();
+
+        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) {
+          // This doc is not competitive enough.
+          // 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);

Review Comment:
   Advancing the priority queue here shouldn't be necessary, we should be able 
to remove this while loop. Scorers will advance on the next call to `advance`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to