diff --git a/lucene/core/src/java/org/apache/lucene/search/DisjunctionScorer.java b/lucene/core/src/java/org/apache/lucene/search/DisjunctionScorer.java index 4a0442c5ceb..09bcdd4f0e6 100644 --- a/lucene/core/src/java/org/apache/lucene/search/DisjunctionScorer.java +++ b/lucene/core/src/java/org/apache/lucene/search/DisjunctionScorer.java @@ -152,13 +152,16 @@ abstract class DisjunctionScorer extends Scorer { previous = w; } } - - // We need to explicitely set the list of top scorers to avoid the - // laziness of DisjunctionScorer.score() that would take all scorers - // positioned on the same doc as the top of the pq, including - // non-matching scorers - DisjunctionScorer.this.topScorers = topScorers; + } else { + // since we don't need scores, let's pretend we have a single match + topScorers.next = null; } + + // We need to explicitely set the list of top scorers to avoid the + // laziness of DisjunctionScorer.score() that would take all scorers + // positioned on the same doc as the top of the pq, including + // non-matching scorers + DisjunctionScorer.this.topScorers = topScorers; return true; } };