From 3d6de9371df3cc8b20d4fa53bae29a771a1be3b1 Mon Sep 17 00:00:00 2001 From: Adrien Grand Date: Tue, 3 Mar 2015 17:58:22 +0000 Subject: [PATCH] LUCENE-6329: Calling score() should be ok even if needsScores is false. git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1663756 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/lucene/search/DisjunctionScorer.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) 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; } };