SpansNot extends BLSpans { @Override public int advance(int doc) throws IOException { alreadyAtFirstMatch = false; if (currentDoc == NO_MORE_DOCS) return NO_MORE_DOCS; if (doc >= maxDoc) { currentDoc = NO_MORE_DOCS; currentStart = currentEnd = clauseStart = NO_MORE_POSITIONS; return NO_MORE_DOCS; } if (currentDoc >= doc) { return nextDoc(); } currentDoc = doc - 1; nextDoc(); return currentDoc; } SpansNot(LeafReader reader, String fieldName, BLSpans clause); @Override int docID(); @Override int endPosition(); @Override int nextDoc(); @Override int nextStartPosition(); @Override int advanceStartPosition(int target); @Override int advance(int doc); @Override int startPosition(); @Override String toString(); @Override void passHitQueryContextToClauses(HitQueryContext context); @Override void getCapturedGroups(Span[] capturedGroups); @Override int width(); @Override void collect(SpanCollector collector); @Override float positionsCost();  }
@Test public void testSpansNotAdvance() throws IOException { Spans exp = MockSpans.fromLists( new int[] { 2, 2, 2, 4, 4, 4, 4, 4 }, new int[] { 0, 2, 4, 0, 1, 2, 3, 4 }, new int[] { 1, 3, 5, 1, 2, 3, 4, 5 }); SpansNot spans = getSpans(); spans.advance(2); TestUtil.assertEquals(exp, spans, true); }
@Test public void testSpansNotAdvanceNoResults() throws IOException { Spans exp = MockSpans.emptySpans(); SpansNot spans = getSpans(); Assert.assertEquals(DocIdSetIterator.NO_MORE_DOCS, spans.advance(5)); TestUtil.assertEquals(exp, spans, true); }
@Test public void testSpansNotAdvanceBeyond() throws IOException { Spans exp = MockSpans.emptySpans(); SpansNot spans = getSpans(); Assert.assertEquals(DocIdSetIterator.NO_MORE_DOCS, spans.advance(1000)); TestUtil.assertEquals(exp, spans, true); }