Skip specialized bulk scorer if two-phase

This commit is contained in:
Adrien Grand 2024-12-03 17:45:22 +01:00
parent 9b314aa155
commit 4ec12bb6ab
1 changed files with 13 additions and 6 deletions

View File

@ -305,7 +305,7 @@ final class BooleanScorerSupplier extends ScorerSupplier {
|| subs.get(Occur.FILTER).isEmpty()
|| scoreMode != ScoreMode.TOP_SCORES
|| subs.get(Occur.SHOULD).size() <= 1
|| minShouldMatch > 1) {
|| minShouldMatch != 1) {
return null;
}
@ -333,6 +333,12 @@ final class BooleanScorerSupplier extends ScorerSupplier {
for (ScorerSupplier ss : subs.get(Occur.FILTER)) {
filters.add(ss.get(cost));
}
if (filters.stream().map(Scorer::twoPhaseIterator).anyMatch(Objects::nonNull)) {
Scorer scoring = new WANDScorer(optionalScorers, minShouldMatch, scoreMode, cost);
filters.add(scoring);
return new DefaultBulkScorer(new ConjunctionScorer(filters, Collections.singleton(scoring)));
} else {
Scorer filterScorer;
if (filters.size() == 1) {
filterScorer = filters.iterator().next();
@ -341,6 +347,7 @@ final class BooleanScorerSupplier extends ScorerSupplier {
}
return new MaxScoreBulkScorer(maxDoc, optionalScorers, filterScorer);
}
}
// Return a BulkScorer for the required clauses only
private BulkScorer requiredBulkScorer() throws IOException {