From 2c04ab58353eb56d254b09ba075ff33e20e9d329 Mon Sep 17 00:00:00 2001 From: Adrien Grand Date: Fri, 14 May 2021 13:55:12 +0200 Subject: [PATCH] LUCENE-9958: Fixed performance regression for boolean queries that configure a minimum number of matching clauses. --- lucene/CHANGES.txt | 3 +++ lucene/core/src/java/org/apache/lucene/search/WANDScorer.java | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) 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;