Skip to content

Apache Lucene open-source search software

LUCENE-8312: Fixed performance regression with non-scoring term queries.

Adrien Grand64573c142c85
diff --git a/lucene/core/src/java/org/apache/lucene/search/TermQuery.java b/lucene/core/src/java/org/apache/lucene/search/TermQuery.java
index 46901f2befd..3fa4aa7e83b 100644
--- a/lucene/core/src/java/org/apache/lucene/search/TermQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/search/TermQuery.java
@@ -114,7 +114,7 @@ public class TermQuery extends Query {
if (scoreMode == ScoreMode.TOP_SCORES) {
return new TermScorer(this, termsEnum.impacts(PostingsEnum.FREQS), scorer);
} else {
- return new TermScorer(this, termsEnum.postings(null, PostingsEnum.FREQS), scorer);
+ return new TermScorer(this, termsEnum.postings(null, scoreMode.needsScores() ? PostingsEnum.FREQS : PostingsEnum.NONE), scorer);
}
}