Skip to content

Commit 7f4d4df

Browse files
authored
LUCENE-9668: Deprecate MinShouldMatchSumScorer with WANDScorer (#2205)
1 parent 93107d6 commit 7f4d4df

File tree

6 files changed

+249
-432
lines changed

6 files changed

+249
-432
lines changed

lucene/core/src/java/org/apache/lucene/search/Boolean2ScorerSupplier.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,15 @@ private Scorer opt(
231231
optionalScorers.add(scorer.get(leadCost));
232232
}
233233

234-
if (scoreMode == ScoreMode.TOP_SCORES) {
235-
return new WANDScorer(weight, optionalScorers, minShouldMatch);
236-
} else if (minShouldMatch > 1) {
237-
return new MinShouldMatchSumScorer(weight, optionalScorers, minShouldMatch);
234+
// Technically speaking, WANDScorer should be able to handle the following 3 conditions now
235+
// 1. Any ScoreMode (with scoring or not)
236+
// 2. Any minCompetitiveScore ( >= 0 )
237+
// 3. Any minShouldMatch ( >= 0 )
238+
//
239+
// However, as WANDScorer uses more complex algorithm and data structure, we would like to
240+
// still use DisjunctionSumScorer to handle exhaustive pure disjunctions, which may be faster
241+
if (scoreMode == ScoreMode.TOP_SCORES || minShouldMatch > 1) {
242+
return new WANDScorer(weight, optionalScorers, minShouldMatch, scoreMode);
238243
} else {
239244
return new DisjunctionSumScorer(weight, optionalScorers, scoreMode);
240245
}

lucene/core/src/java/org/apache/lucene/search/BooleanScorer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ void score(LeafCollector collector, Bits acceptDocs, int min, int max) throws IO
6161
}
6262
}
6363

64-
// See MinShouldMatchSumScorer for an explanation
64+
// See WANDScorer for an explanation
6565
private static long cost(Collection<BulkScorer> scorers, int minShouldMatch) {
6666
final PriorityQueue<BulkScorer> pq =
6767
new PriorityQueue<BulkScorer>(scorers.size() - minShouldMatch + 1) {

0 commit comments

Comments
 (0)