@Override public int doc() { return conjunctionScorer.doc(); }
public NodeConjunctionScorer(final Weight weight, final float coord, final NodeScorer ... scorers) throws IOException { super(weight); this.scorers = scorers; this.coord = coord; this.init(); }
@Override public boolean nextCandidateDocument() throws IOException { freq = 0.0f; // reset freq return conjunctionScorer.nextCandidateDocument(); }
if (!this.doNext()) {
@Override public float scoreInNode() throws IOException { return conjunctionScorer.scoreInNode(); }
@Override public IntsRef node() { return conjunctionScorer.node(); }
@Override public boolean skipToCandidate(final int target) throws IOException { return conjunctionScorer.skipToCandidate(target); }
@Override public boolean nextNode() throws IOException { freq = 0.0f; // reset freq while (conjunctionScorer.nextNode()) { // if node contains phrase-query terms if (this.firstPhrase()) { // check for phrase freq = this.phraseFreq(); // compute frequency of the phrase return true; } } return false; }
NodePhraseScorer(final Weight weight, final NodePhraseQuery.PostingsAndPosition[] postings, final Similarity.SloppySimScorer sloppyScorer, final Similarity.ExactSimScorer exactScorer) throws IOException { super(weight); this.sloppyScorer = sloppyScorer; this.exactScorer = exactScorer; // convert tps to a list of phrase positions. // note: phrase-position differs from term-position in that its position // reflects the phrase offset: pp.pos = tp.pos - offset. // this allows to easily identify a matching (exact) phrase // when all PhrasePositions have exactly the same position. phrasePositions = new NodePhrasePosition[postings.length]; for (int i = 0; i < postings.length; i++) { phrasePositions[i] = new NodePhrasePosition(postings[i].postings, postings[i].position); } // create node conjunction scorer final NodeScorer[] scorers = new NodeScorer[postings.length]; for (int i = 0; i < postings.length; i++) { scorers[i] = new NodeTermScorer(weight, postings[i].postings, exactScorer); } conjunctionScorer = new NodeConjunctionScorer(weight, 1.0f, scorers); }
@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; }
@Override public float scoreInNode() throws IOException { final float nodeScore = super.scoreInNode(); coordinator.nrMatchers += requiredNrMatchers; // All scorers match, so defaultSimilarity super.score() always has 1 as // the coordination factor. // Therefore the sum of the scores of the requiredScorers // is used as score. return nodeScore; } };
@Override public boolean nextCandidateDocument() throws IOException { if (lastDocument == DocsAndNodesIterator.NO_MORE_DOC) { return false; } else if (lastDocument == -1) { // first time called lastDocument = scorers[scorers.length - 1].doc(); lastNode = scorers[scorers.length - 1].node(); return true; } // advance the last scorer to the next candidate document scorers[(scorers.length - 1)].nextCandidateDocument(); final boolean more = this.doNext(); lastDocument = scorers[scorers.length - 1].doc(); lastNode = scorers[scorers.length - 1].node(); return more; }