Skip to content

Apache Lucene open-source search software

LUCENE-9958: Fixed performance regression for boolean queries that configure a minimum number of matching clauses.

Adrien Grand2c04ab58353e
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 53fcf11ca40..50385fd7cdb 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -383,6 +383,9 @@ Bug Fixes
* LUCENE-9887: Fixed parameter use in RadixSelector.
(liupanfeng via Adrien Grand)
+* LUCENE-9958: Fixed performance regression for boolean queries that configure a
+ minimum number of matching clauses. (Adrien Grand, Matt Weber)
+
Other
---------------------
diff --git a/lucene/core/src/java/org/apache/lucene/search/WANDScorer.java b/lucene/core/src/java/org/apache/lucene/search/WANDScorer.java
index f33af6b8ee8..48e3a2c30f0 100644
--- a/lucene/core/src/java/org/apache/lucene/search/WANDScorer.java
+++ b/lucene/core/src/java/org/apache/lucene/search/WANDScorer.java
@@ -548,7 +548,7 @@ final class WANDScorer extends Scorer {
/** Insert an entry in 'tail' and evict the least-costly scorer if full. */
private DisiWrapper insertTailWithOverFlow(DisiWrapper s) {
- if (tailMaxScore + s.maxScore < minCompetitiveScore) {
+ if (tailMaxScore + s.maxScore < minCompetitiveScore || tailSize + 1 < minShouldMatch) {
// we have free room for this new entry
addTail(s);
tailMaxScore += s.maxScore;