mirror of https://github.com/apache/lucene.git
LUCENE-9566 TestApproximationSearchEquivalence.testExclusion fix (#1955)
This commit is contained in:
parent
2a8136b3fd
commit
0b08943112
|
@ -210,7 +210,7 @@ public abstract class Weight implements SegmentCacheable {
|
|||
} else {
|
||||
if (scorerIterator.docID() != -1) {
|
||||
// Wrap ScorerIterator to start from -1 for conjunction
|
||||
scorerIterator = new RangeDISIWrapper(scorerIterator, max);
|
||||
scorerIterator = new StartDISIWrapper(scorerIterator);
|
||||
}
|
||||
// filter scorerIterator to keep only competitive docs as defined by collector
|
||||
filteredIterator = ConjunctionDISI.intersectIterators(Arrays.asList(scorerIterator, collectorIterator));
|
||||
|
@ -277,16 +277,14 @@ public abstract class Weight implements SegmentCacheable {
|
|||
/**
|
||||
* Wraps an internal docIdSetIterator for it to start with docID = -1
|
||||
*/
|
||||
protected static class RangeDISIWrapper extends DocIdSetIterator {
|
||||
protected static class StartDISIWrapper extends DocIdSetIterator {
|
||||
private final DocIdSetIterator in;
|
||||
private final int min;
|
||||
private final int max;
|
||||
private int docID = -1;
|
||||
|
||||
public RangeDISIWrapper(DocIdSetIterator in, int max) {
|
||||
public StartDISIWrapper(DocIdSetIterator in) {
|
||||
this.in = in;
|
||||
this.min = in.docID();
|
||||
this.max = max;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -301,16 +299,15 @@ public abstract class Weight implements SegmentCacheable {
|
|||
|
||||
@Override
|
||||
public int advance(int target) throws IOException {
|
||||
target = Math.max(min, target);
|
||||
if (target >= max) {
|
||||
return docID = NO_MORE_DOCS;
|
||||
if (target <= min) {
|
||||
return docID = min;
|
||||
}
|
||||
return docID = in.advance(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long cost() {
|
||||
return Math.min(max - min, in.cost());
|
||||
return in.cost();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -196,7 +196,6 @@ public class TestApproximationSearchEquivalence extends SearchEquivalenceTestBas
|
|||
assertSameScores(bq1.build(), bq2.build());
|
||||
}
|
||||
|
||||
@AwaitsFix(bugUrl = "https://issues.apache.org/jira/browse/LUCENE-9566")
|
||||
public void testExclusion() throws Exception {
|
||||
Term t1 = randomTerm();
|
||||
Term t2 = randomTerm();
|
||||
|
|
Loading…
Reference in New Issue