@Override protected void setAncestorPointer(final NodeQuery ancestor) { super.setAncestorPointer(ancestor); // keep root query synchronised with twig query root.setAncestorPointer(ancestor); }
@Override protected void setAncestorPointer(final NodeQuery ancestor) { super.setAncestorPointer(ancestor); // keep clauses synchronised for (final NodeBooleanClause clause : clauses) { clause.getQuery().setAncestorPointer(ancestor); } }
@Override protected void setAncestorPointer(final NodeQuery ancestor) { super.setAncestorPointer(ancestor); // keep encapsulated query synchronised query.setAncestorPointer(ancestor); }
@Override protected void initWeights(final IndexSearcher searcher) throws IOException { weights = new ArrayList<Weight>(clauses.size()); for (int i = 0; i < clauses.size(); i++) { final NodeBooleanClause c = clauses.get(i); final NodeQuery q = c.getQuery(); // pass to child query the node contraints q.setNodeConstraint(lowerBound, upperBound); q.setLevelConstraint(levelConstraint); // transfer ancestor pointer to child q.setAncestorPointer(ancestor); weights.add(q.createWeight(searcher)); } }
private TwigQuery rewriteRoot(TwigQuery clone, final IndexReader reader) throws IOException { final NodeQuery query = (NodeQuery) root.rewrite(reader); if (query != root) { if (clone == null) { clone = (TwigQuery) this.clone(); } // copy ancestor query.setAncestorPointer(ancestor); clone.root = query; } return clone; }
/** * Adds a root query. * <p> * Overwrite the level and node constraints of the root query with the * currently defined level and node constraints of the twig query. */ public void addRoot(final NodeQuery root) { this.root = root; // set the node constraint= root.setNodeConstraint(lowerBound, upperBound); // set level constraint root.setLevelConstraint(levelConstraint); // set the ancestor root.setAncestorPointer(ancestor); }
/** * Adds a descendant clause to the twig query. The node level of the * descendant is relative to the twig level. * * @throws TooManyClauses * if the new number of clauses exceeds the maximum clause number * @see #getMaxClauseCount() */ public void addDescendant(final int nodeLevel, final NodeQuery query, final NodeBooleanClause.Occur occur) { if (nodeLevel <= 0) { throw new IllegalArgumentException("The node level of a descendant should be superior to 0"); } // set the level constraint on the query query.setLevelConstraint(levelConstraint + nodeLevel); // set the ancestor pointer query.setAncestorPointer(root); // add the query to the clauses this.addClause(new NodeBooleanClause(query, occur)); }
private TwigQuery rewriteClauses(TwigQuery clone, final IndexReader reader) throws IOException { for (int i = 0 ; i < clauses.size(); i++) { final NodeBooleanClause c = clauses.get(i); final NodeQuery query = (NodeQuery) c.getQuery().rewrite(reader); if (query != c.getQuery()) { // clause rewrote: must clone if (clone == null) { clone = (TwigQuery) this.clone(); // clone and set root since clone is null, i.e., root has not been rewritten clone.root = (NodeQuery) this.root.clone(); // copy ancestor clone.root.setAncestorPointer(ancestor); } // set root as ancestor query.setAncestorPointer(clone.root); clone.clauses.set(i, new NodeBooleanClause(query, c.getOccur())); } } return clone; }
/** * Adds a child clause to the twig query. * * @throws TooManyClauses * if the new number of clauses exceeds the maximum clause number * @see #getMaxClauseCount() */ public void addChild(final NodeQuery query, final NodeBooleanClause.Occur occur) { // set the level constraint on the query query.setLevelConstraint(levelConstraint + 1); // set the ancestor pointer query.setAncestorPointer(root); // add the query to the clauses this.addClause(new NodeBooleanClause(query, occur)); }
/** * Adds a clause to a boolean query. * * @throws TooManyClauses * if the new number of clauses exceeds the maximum clause number * @see #getMaxClauseCount() */ public void add(final NodeBooleanClause clause) { if (clauses.size() >= maxClauseCount) { throw new TooManyClauses(); } clauses.add(clause); // keep clause synchronised in term of constraint management clause.getQuery().setLevelConstraint(levelConstraint); clause.getQuery().setNodeConstraint(lowerBound, upperBound); clause.getQuery().setAncestorPointer(ancestor); }
query.setAncestorPointer(ancestor); query.setAncestorPointer(ancestor);
query.setAncestorPointer(ancestor); query.setAncestorPointer(ancestor); ((AncestorFilterQuery) query).getQuery().setAncestorPointer(query); clause.getQuery().setAncestorPointer(clone.root);
result.setNodeConstraint(query.getNodeConstraint()[0], query.getNodeConstraint()[1]); result.setAncestorPointer(query.ancestor);