This is an automated email from the ASF dual-hosted git repository.

hossman pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/main by this push:
     new 5782bdc0b65 SOLR-17940: Fix DelegatingCollector to prevent the 
delegate from calling setMinCompetitiveScore if the scoreMode is not TOP_SCORES
5782bdc0b65 is described below

commit 5782bdc0b650b1e1a09a1b5e0260785f3e13d95e
Author: Chris Hostetter <[email protected]>
AuthorDate: Wed Oct 1 17:16:32 2025 -0700

    SOLR-17940: Fix DelegatingCollector to prevent the delegate from calling 
setMinCompetitiveScore if the scoreMode is not TOP_SCORES
---
 solr/CHANGES.txt                                       |  2 ++
 .../org/apache/solr/search/DelegatingCollector.java    | 18 ++++++++++++++++--
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 1dd816513ae..d47d93b2d0a 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -86,6 +86,8 @@ Bug Fixes
 * SOLR-17772: Tests for CLI examples were failing on Windows due to a legacy 
bug uncovered by fix in SOLR-7962.
   Additionally achieves simplification of CLI tests (Rahul Goswami via Eric 
Pugh)
 
+* SOLR-17940: Fix DelegatingCollector to prevent the delegate from calling 
setMinCompetitiveScore if the scoreMode is not TOP_SCORES (hossman)
+
 Deprecation Removals
 ----------------------
 
diff --git a/solr/core/src/java/org/apache/solr/search/DelegatingCollector.java 
b/solr/core/src/java/org/apache/solr/search/DelegatingCollector.java
index af9b669f01f..b775e9d6553 100644
--- a/solr/core/src/java/org/apache/solr/search/DelegatingCollector.java
+++ b/solr/core/src/java/org/apache/solr/search/DelegatingCollector.java
@@ -19,6 +19,7 @@ package org.apache.solr.search;
 import java.io.IOException;
 import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.search.Collector;
+import org.apache.lucene.search.FilterScorable;
 import org.apache.lucene.search.LeafCollector;
 import org.apache.lucene.search.Scorable;
 import org.apache.lucene.search.ScoreMode;
@@ -57,9 +58,22 @@ public class DelegatingCollector extends SimpleCollector {
 
   @Override
   public void setScorer(Scorable scorer) throws IOException {
-    this.scorer = scorer;
+    // Inspired by Lucene's MultiLeafCollector
+    if (scoreMode() == ScoreMode.TOP_SCORES) {
+      this.scorer = scorer;
+    } else {
+      this.scorer =
+          new FilterScorable(scorer) {
+            @Override
+            public void setMinCompetitiveScore(float minScore) throws 
IOException {
+              // Ignore calls to setMinCompetitiveScore so that if we wrap a
+              // collector that wants to skip low-scoring hits, then the
+              // outer collector (that set scoreMode) still sees all hits.
+            }
+          };
+    }
     if (leafDelegate != null) {
-      leafDelegate.setScorer(scorer);
+      leafDelegate.setScorer(this.scorer);
     }
   }
 

Reply via email to