@Override protected void addClause(final NodeBooleanQuery topLevel, final Term term, final int docFreq, final float boost, final TermContext states) { final NodePrimitiveQuery q = new NodeConstantScoreQuery(new NodeTermQuery(term, states)); q.setBoost(boost); topLevel.add(q, NodeBooleanClause.Occur.SHOULD); } }
@Override protected void setAncestorPointer(final NodeQuery ancestor) { super.setAncestorPointer(ancestor); // keep clauses synchronised for (final NodeBooleanClause clause : clauses) { clause.getQuery().setAncestorPointer(ancestor); } }
@Override public void extractTerms(final Set<Term> terms) { for (final NodeBooleanClause clause : clauses) { clause.getQuery().extractTerms(terms); } }
@Override protected void addClause(final NodeBooleanQuery topLevel, final Term term, final int docCount, final float boost, final TermContext states) { final NodeTermQuery tq = new NodeTermQuery(term, states); tq.setBoost(boost); topLevel.add(tq, Occur.SHOULD); }
@Override public int advance(final int target) throws IOException { if (scorer.skipToCandidate(target)) { do { if (scorer.nextNode()) { return this.docID(); } } while (scorer.nextCandidateDocument()); } return NO_MORE_DOCS; }
@Override public NodeQuery rewrite(final IndexReader reader) throws IOException { if (query != null) { NodeQuery rewritten = (NodeQuery) query.rewrite(reader); if (rewritten != query) { rewritten = new NodeConstantScoreQuery(rewritten); rewritten.setBoost(this.getBoost()); return rewritten; } } return this; }
@Override public int nextDoc() throws IOException { while (scorer.nextCandidateDocument()) { if (scorer.nextNode()) { // check if there is at least 1 node that matches the query return this.docID(); } } return NO_MORE_DOCS; }
@Override public void setLevelConstraint(final int levelConstraint) { super.setLevelConstraint(levelConstraint); // keep clauses synchronised for (final NodeBooleanClause clause : clauses) { clause.getQuery().setLevelConstraint(levelConstraint); } }
@Override public void setLevelConstraint(final int levelConstraint) { super.setLevelConstraint(levelConstraint); // keep encapsulated query synchronised query.setLevelConstraint(levelConstraint); }
@Override public void setNodeConstraint(final int lowerBound, final int upperBound) { super.setNodeConstraint(lowerBound, upperBound); // keep encapsulated query synchronised query.setNodeConstraint(lowerBound, upperBound); }
@Override public boolean nextCandidateDocument() throws IOException { if (!reqScorer.nextCandidateDocument()) { return false; } if (exclScorer == null) { return true; // reqScorer.nextCandidateDocument() already returned true } return this.toNonExcludedCandidateDocument(); }
@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; }
@Override public Weight createWeight(final IndexSearcher searcher) throws IOException { return new LuceneProxyNodeWeight(nodeQuery.createWeight(searcher)); }
@Override boolean firstPhrase() throws IOException { for (final NodePhrasePosition phrasePosition : phrasePositions) { phrasePosition.init(); } // check for phrase return this.nextPhrase(); }
private NodeScorer countingDisjunctionSumScorer(final List<NodeScorer> scorers) throws IOException { return new NodeDisjunctionScorer(this.getWeight(), scorers) { @Override public float scoreInNode() throws IOException { final float nodeScore = super.scoreInNode(); coordinator.nrMatchers += super.nrMatchers(); return nodeScore; } }; }
@Override public boolean equals(final Object o) { if (!(o instanceof AncestorFilterQuery)) { return false; } final AncestorFilterQuery other = (AncestorFilterQuery) o; return (this.getBoost() == other.getBoost()) && this.q.equals(other.q) && this.lowerBound == other.lowerBound && this.upperBound == other.upperBound && this.levelConstraint == other.levelConstraint; }
private void retrieveConstraint(final NodeQuery query, final ConstraintStack stack) { if (query == null) { return; } // add a constraint only if lower and upper bounds are defined if (query.lowerBound != -1 && query.upperBound != -1) { stack.add(query.levelConstraint, query.lowerBound, query.upperBound); } // recursively traverse the ancestors this.retrieveConstraint(query.ancestor, stack); }
@Override protected void addClause(final NodeBooleanQuery topLevel, final Term term, final int docCount, final float boost, final TermContext states) { final NodeTermQuery tq = new NodeTermQuery(term, states); tq.setBoost(boost); topLevel.add(tq, Occur.SHOULD); }