mirror of https://github.com/apache/lucene.git
LUCENE-1583: SpanOrQuery skipTo() doesn't always move forwards as Spans documentation indicates it should.
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@794063 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b393e4d0af
commit
6bf4d35ce8
|
@ -378,6 +378,9 @@ Bug fixes
|
|||
|
||||
18. LUCENE-1718: Fix termInfosIndexDivisor to carry over to reopened
|
||||
readers (Mike McCandless)
|
||||
|
||||
19. LUCENE-1583: SpanOrQuery skipTo() doesn't always move forwards as Spans
|
||||
documentation indicates it should. (Moti Nisenson via Mark Miller)
|
||||
|
||||
New features
|
||||
|
||||
|
|
|
@ -215,16 +215,21 @@ public class SpanOrQuery extends SpanQuery implements Cloneable {
|
|||
if (queue == null) {
|
||||
return initSpanQueue(target);
|
||||
}
|
||||
|
||||
|
||||
boolean skipCalled = false;
|
||||
while (queue.size() != 0 && top().doc() < target) {
|
||||
if (top().skipTo(target)) {
|
||||
queue.adjustTop();
|
||||
} else {
|
||||
queue.pop();
|
||||
}
|
||||
skipCalled = true;
|
||||
}
|
||||
|
||||
return queue.size() != 0;
|
||||
|
||||
if (skipCalled) {
|
||||
return queue.size() != 0;
|
||||
}
|
||||
return next();
|
||||
}
|
||||
|
||||
public int doc() { return top().doc(); }
|
||||
|
|
|
@ -331,6 +331,23 @@ public class TestSpans extends LuceneTestCase {
|
|||
assertFalse("final next", spans.next());
|
||||
}
|
||||
|
||||
public void testSpanOrMovesForward() throws Exception {
|
||||
Spans spans = orSpans(new String[] {"w1", "xx"});
|
||||
|
||||
spans.next();
|
||||
int doc = spans.doc();
|
||||
assertEquals(0, doc);
|
||||
|
||||
spans.skipTo(0);
|
||||
doc = spans.doc();
|
||||
|
||||
// LUCENE-1583:
|
||||
// according to Spans, a skipTo to the same doc or less
|
||||
// should still call next() on the underlying Spans
|
||||
assertEquals(1, doc);
|
||||
|
||||
}
|
||||
|
||||
public void testSpanOrDouble() throws Exception {
|
||||
Spans spans = orSpans(new String[] {"w5", "yy"});
|
||||
tstNextSpans(spans, 0, 4, 5);
|
||||
|
|
Loading…
Reference in New Issue