@Override public int doc() { return reqScorer.doc(); // reqScorer may be null when next() or skipTo() // already return false }
@Override public int doc() { return scorer.doc(); }
@Override public int doc() { return scorer.doc(); }
@Override public int doc() { return countingSumScorer.doc(); }
@Override public int docID() { return scorer.doc(); }
@Override public int doc() { return scorer.doc(); }
@Override public int doc() { return reqScorer.doc(); }
@Override public int doc() { return scorer.doc(); }
@Override public boolean nextNode() throws IOException { if (!reqScorer.nextNode()) { // Move to the next matching node return false; // exhausted, nothing left } if (exclScorer == null || exclScorer.doc() != reqScorer.doc()) { return true; // reqScorer.nextNode() already returned true } // reqScorer and exclScorer are positioned on the same candidate document return this.toNonExcludedNode(); }
void adjust() { doc = scorer.doc(); node = scorer.node(); }
@Override public boolean skipToCandidate(final int target) throws IOException { if (lastDocument == DocsAndNodesIterator.NO_MORE_DOC) { return false; } else if (scorers[(scorers.length - 1)].doc() < target) { scorers[(scorers.length - 1)].skipToCandidate(target); } final boolean more = this.doNext(); lastDocument = scorers[scorers.length - 1].doc(); lastNode = scorers[scorers.length - 1].node(); return more; }
/** * Compares the given scorer with the specified heaped scorer for order. * Returns a negative integer, zero, or a positive integer as this scorer is * less than, equal to, or greater than the specified heaped scorer. */ private int compareTo(final NodeScorer scorer, final NodeScorer other) { // compare docs final int doc = scorer.doc(); final int otherDoc = other.doc(); if (doc != otherDoc) { return doc - otherDoc; } // compare nodes return NodeUtils.compare(scorer.node(), other.node()); }
@Override public Explanation explain(final AtomicReaderContext context, final int doc) throws IOException { final NodeScorer scorer = (NodeScorer) this.scorer(context, context.reader().getLiveDocs()); if (scorer != null) { if (scorer.skipToCandidate(doc) && scorer.doc() == doc) { return weight.explain(context, doc); } } return new ComplexExplanation(false, 0.0f, "no matching term"); }
@Override public Explanation explain(final AtomicReaderContext context, final int doc) throws IOException { final NodeScorer scorer = (NodeScorer) this.scorer(context, context.reader().getLiveDocs()); if (scorer != null) { if (scorer.skipToCandidate(doc) && scorer.doc() == doc) { return weight.explain(context, doc); } } return new ComplexExplanation(false, 0.0f, "no matching term"); }
@Override public Explanation explain(final AtomicReaderContext context, final int doc) throws IOException { final NodeScorer scorer = (NodeScorer) this.scorer(context, context.reader().getLiveDocs()); if (scorer != null) { if (scorer.skipToCandidate(doc) && scorer.doc() == doc && scorer.nextNode()) { return includeWeight.explain(context, doc); } } return new ComplexExplanation(false, 0.0f, "no matching term"); }
/** * Assert if a scorer reaches end of stream, and check if sentinel values are * set. */ public static void assertEndOfStream(final NodeScorer scorer) throws IOException { assertFalse(scorer.nextCandidateDocument()); assertEquals(DocsAndNodesIterator.NO_MORE_DOC, scorer.doc()); assertFalse(scorer.nextNode()); assertEquals(DocsAndNodesIterator.NO_MORE_NOD, scorer.node()); }
@Test public void testLevelConstraint() throws Exception { this.addDocument("<http://renaud.delbru.fr/> . "); NodeScorer scorer = this.getScorer(ntq("renaud").level(1)); assertTrue(scorer.nextCandidateDocument()); assertEquals(0, scorer.doc()); assertFalse(scorer.nextNode()); scorer = this.getScorer(ntq("renaud").level(3)); assertTrue(scorer.nextCandidateDocument()); assertEquals(0, scorer.doc()); assertFalse(scorer.nextNode()); scorer = this.getScorer(ntq("renaud").level(2)); assertTrue(scorer.nextCandidateDocument()); assertEquals(0, scorer.doc()); assertTrue(scorer.nextNode()); assertEquals(node(0,0), scorer.node()); }
@Test public void testIntervalConstraint() throws Exception { this.addDocument("<http://renaud.delbru.fr/> . "); NodeScorer scorer = this.getScorer(ntq("renaud").bound(1,1)); assertTrue(scorer.nextCandidateDocument()); assertEquals(0, scorer.doc()); assertFalse(scorer.nextNode()); scorer = this.getScorer(ntq("renaud").bound(1,2)); assertTrue(scorer.nextCandidateDocument()); assertEquals(0, scorer.doc()); assertFalse(scorer.nextNode()); scorer = this.getScorer(ntq("renaud").bound(0,0)); assertTrue(scorer.nextCandidateDocument()); assertEquals(0, scorer.doc()); assertTrue(scorer.nextNode()); assertEquals(node(0,0), scorer.node()); }
@Test public void testNextWithPhraseExclusion2() throws Exception { this.addDocument("\"aaa bbb ccc\" . \"ccc aaa bbb\" . "); final NodeScorer scorer = this.getScorer( nbq(must(npq("aaa", "bbb")), not(npq("bbb", "ccc"))) ); assertTrue(scorer.nextCandidateDocument()); assertEquals(0, scorer.doc()); assertEquals(node(-1), scorer.node()); assertTrue(scorer.nextNode()); assertEquals(node(1,0), scorer.node()); assertFalse(scorer.nextNode()); assertEquals(DocsAndNodesIterator.NO_MORE_NOD, scorer.node()); assertEndOfStream(scorer); }