Fix test failure.

This commit is contained in:
Adrien Grand 2023-09-25 13:54:08 +02:00
parent 483d28853a
commit ce464c7d6d
2 changed files with 5 additions and 3 deletions

View File

@ -40,8 +40,9 @@ final class BlockMaxConjunctionBulkScorer extends BulkScorer {
private final DocIdSetIterator lead;
private final DocAndScore scorable = new DocAndScore();
private final double[] sumOfOtherClauses;
private final int maxDoc;
BlockMaxConjunctionBulkScorer(List<Scorer> scorers) throws IOException {
BlockMaxConjunctionBulkScorer(int maxDoc, List<Scorer> scorers) throws IOException {
if (scorers.size() <= 1) {
throw new IllegalArgumentException("Expected 2 or more scorers, got " + scorers.size());
}
@ -51,6 +52,7 @@ final class BlockMaxConjunctionBulkScorer extends BulkScorer {
Arrays.stream(this.scorers).map(Scorer::iterator).toArray(DocIdSetIterator[]::new);
lead = iterators[0];
this.sumOfOtherClauses = new double[this.scorers.length];
this.maxDoc = maxDoc;
}
@Override
@ -79,7 +81,7 @@ final class BlockMaxConjunctionBulkScorer extends BulkScorer {
windowMin = Math.max(lead.docID(), windowMax + 1);
}
return windowMin;
return windowMin >= maxDoc ? DocIdSetIterator.NO_MORE_DOCS : windowMin;
}
private void scoreWindow(

View File

@ -315,7 +315,7 @@ final class BooleanWeight extends Weight {
&& requiredScoring.size() > 1
// Only specialize top-level conjunctions for clauses that don't have a two-phase iterator.
&& requiredScoring.stream().map(Scorer::twoPhaseIterator).allMatch(Objects::isNull)) {
return new BlockMaxConjunctionBulkScorer(requiredScoring);
return new BlockMaxConjunctionBulkScorer(context.reader().maxDoc(), requiredScoring);
}
if (scoreMode == ScoreMode.TOP_SCORES && requiredScoring.size() > 1) {
requiredScoring =