/** * Create a new node query with the specified boolean expression * <p> * The boolean expression must follow the syntax of the * {@link com.sindicetech.siren.qparser.keyword.ExtendedKeywordQueryParser}. */ public NodeQuery newNode(final String booleanExpression) throws QueryNodeException { final NodeQuery node = new NodeQuery(mapper, parser); node.setBooleanExpression(booleanExpression); return node; }
@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 ObjectNode toJson() { final ObjectNode obj = mapper.createObjectNode(); final ObjectNode node = obj.putObject(NodePropertyParser.NODE_PROPERTY); node.put(QueryPropertyParser.QUERY_PROPERTY, booleanExpression); if (this.hasLevel()) { node.put(LevelPropertyParser.LEVEL_PROPERTY, this.getLevel()); } if (this.hasRange()) { final ArrayNode array = node.putArray(RangePropertyParser.RANGE_PROPERTY); array.add(this.getLowerBound()); array.add(this.getUpperBound()); } if (this.hasBoost()) { node.put(BoostPropertyParser.BOOST_PROPERTY, this.getBoost()); } return obj; }