@Override public void setNodeConstraint(final int lowerBound, final int upperBound) { super.setNodeConstraint(lowerBound, upperBound); // keep root query synchronised with twig query root.setNodeConstraint(lowerBound, upperBound); }
/** * Set the node index constraint. */ public void setNodeConstraint(final int index) { this.setNodeConstraint(index, index); }
@Override public void setNodeConstraint(final int lowerBound, final int upperBound) { super.setNodeConstraint(lowerBound, upperBound); // keep clauses synchronised for (final NodeBooleanClause clause : clauses) { clause.getQuery().setNodeConstraint(lowerBound, upperBound); } }
@Override public void setNodeConstraint(final int lowerBound, final int upperBound) { super.setNodeConstraint(lowerBound, upperBound); this.query.setNodeConstraint(lowerBound, upperBound); }
@Override public void setNodeConstraint(final int lowerBound, final int upperBound) { super.setNodeConstraint(lowerBound, upperBound); // keep encapsulated query synchronised query.setNodeConstraint(lowerBound, upperBound); }
@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 constraints q.setNodeConstraint(lowerBound, upperBound); q.setLevelConstraint(levelConstraint); // transfer ancestor pointer to child q.setAncestorPointer(ancestor); weights.add(q.createWeight(searcher)); } }
/** * 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); }
public NodeQueryBuilder bound(final int lowerBound, final int upperBound) { ((NodeQuery) this.getQuery()).setNodeConstraint(lowerBound, upperBound); return this; }
/** * 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 the clause synchronised in term of constraint management clause.getQuery().setLevelConstraint(levelConstraint); clause.getQuery().setNodeConstraint(lowerBound, upperBound); clause.getQuery().setAncestorPointer(ancestor); }
@Override public Query rewrite(final IndexReader reader) throws IOException { NodeSpanQuery clone = null; NodeQuery rewritten = (NodeQuery) this.query.rewrite(reader); if (rewritten != this.query) { clone = this.clone(); // transfer constraints rewritten.setNodeConstraint(lowerBound, upperBound); rewritten.setLevelConstraint(levelConstraint); // transfer ancestor pointer rewritten.setAncestorPointer(ancestor); clone.query = rewritten; } if (clone != null) { return clone; // some clauses rewrote } else { return this; // no clauses rewrote } }
@Override public NodeQuery build(final QueryNode queryNode) throws QueryNodeException { final NodeQueryNode node = (NodeQueryNode) queryNode; final String field = node.getField().toString(); final String expr = node.getValue().toString(); final NodeQuery query = (NodeQuery) keywordParser.parse(expr, field); // check if the node has a level constraint if (node.getTag(LevelPropertyParser.LEVEL_PROPERTY) != null) { query.setLevelConstraint((Integer) node.getTag(LevelPropertyParser.LEVEL_PROPERTY)); } // check if the node has a node range constraint if (node.getTag(RangePropertyParser.RANGE_PROPERTY) != null) { final int[] range = (int[]) node.getTag(RangePropertyParser.RANGE_PROPERTY); query.setNodeConstraint(range[0], range[1]); } return query; }
@Override public NodeQuery build(final QueryNode queryNode) throws QueryNodeException { final NodeQueryNode node = (NodeQueryNode) queryNode; final String field = node.getField().toString(); final String expr = node.getValue().toString(); // ensure that the attribute is unset keywordParser.unsetAttribute(); // set attribute if (node.getAttribute() != null) { keywordParser.setAttribute(node.getAttribute().toString()); } final NodeQuery query = (NodeQuery) keywordParser.parse(expr, field); // check if the node has a level constraint if (node.getTag(LevelPropertyParser.LEVEL_PROPERTY) != null) { query.setLevelConstraint((Integer) node.getTag(LevelPropertyParser.LEVEL_PROPERTY)); } // check if the node has a node range constraint if (node.getTag(RangePropertyParser.RANGE_PROPERTY) != null) { final int[] range = (int[]) node.getTag(RangePropertyParser.RANGE_PROPERTY); query.setNodeConstraint(range[0], range[1]); } return query; }
query.setNodeConstraint(lowerBound, upperBound); query.setLevelConstraint(levelConstraint); query.setNodeConstraint(lowerBound, upperBound); query.setLevelConstraint(levelConstraint);
@Override public Query toQuery(final boolean proxy) throws QueryNodeException { final com.sindicetech.siren.search.node.NodeQuery query = (com.sindicetech.siren.search.node.NodeQuery) parser.parse(booleanExpression, ""); if (this.hasLevel()) { query.setLevelConstraint(this.getLevel()); } if (this.hasRange()) { query.setNodeConstraint(this.getLowerBound(), this.getUpperBound()); } if (this.hasBoost()) { query.setBoost(this.getBoost()); } // should we wrap the query into a lucene proxy if (proxy) { return new LuceneProxyNodeQuery(query); } return query; }
@Override public Query toQuery(final boolean proxy) throws QueryNodeException { // ensure that the attribute is unset ((ConciseKeywordQueryParser) parser).unsetAttribute(); // set attribute if (this.hasAttribute) { ((ConciseKeywordQueryParser) parser).setAttribute(attribute); } final com.sindicetech.siren.search.node.NodeQuery query = (com.sindicetech.siren.search.node.NodeQuery) parser.parse(booleanExpression, ""); if (this.hasLevel()) { query.setLevelConstraint(this.getLevel()); } if (this.hasRange()) { query.setNodeConstraint(this.getLowerBound(), this.getUpperBound()); } if (this.hasBoost()) { query.setBoost(this.getBoost()); } // should we wrap the query into a lucene proxy if (proxy) { return new LuceneProxyNodeQuery(query); } return query; }
query.setNodeConstraint(lowerBound, upperBound);