Skip to content

Commit

Permalink
LUCENE-9555: Advance conjunction Iterator for two phase iteration (ap…
Browse files Browse the repository at this point in the history
…ache#1943)

PR apache#1351 introduced a sort optimization where
documents can be skipped.
But there was a bug in case we were using two phase
approximation, as we would advance it without advancing
an overall conjunction iterator.

This patch fixed it.

Relates to apache#1351
  • Loading branch information
mayya-sharipova authored Oct 6, 2020
1 parent b45c43f commit 6ac94a6
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lucene/core/src/java/org/apache/lucene/search/Weight.java
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,11 @@ static int scoreRange(LeafCollector collector, DocIdSetIterator iterator, TwoPha
}
return currentDoc;
} else {
final DocIdSetIterator approximation = twoPhase.approximation();
while (currentDoc < end) {
if ((acceptDocs == null || acceptDocs.get(currentDoc)) && twoPhase.matches()) {
collector.collect(currentDoc);
}
currentDoc = approximation.nextDoc();
currentDoc = iterator.nextDoc();
}
return currentDoc;
}
Expand All @@ -258,8 +257,7 @@ static void scoreAll(LeafCollector collector, DocIdSetIterator iterator, TwoPhas
}
} else {
// The scorer has an approximation, so run the approximation first, then check acceptDocs, then confirm
final DocIdSetIterator approximation = twoPhase.approximation();
for (int doc = approximation.nextDoc(); doc != DocIdSetIterator.NO_MORE_DOCS; doc = approximation.nextDoc()) {
for (int doc = iterator.nextDoc(); doc != DocIdSetIterator.NO_MORE_DOCS; doc = iterator.nextDoc()) {
if ((acceptDocs == null || acceptDocs.get(doc)) && twoPhase.matches()) {
collector.collect(doc);
}
Expand Down

0 comments on commit 6ac94a6

Please sign in to comment.