public Query build(final QueryNode queryNode) throws QueryNodeException { final BoostQueryNode boostNode = (BoostQueryNode) queryNode; final QueryNode child = boostNode.getChild(); if (child == null) { return null; } final Query query = (Query) child .getTag(QueryTreeBuilder.QUERY_TREE_BUILDER_TAGID); query.setBoost(boostNode.getValue()); return query; }
/** * Constructs a boost node * * @param query * the query to be boosted * @param value * the boost value, it may vary from 0.0 to 1.0 */ public BoostQueryNode(QueryNode query, float value) { if (query == null) { throw new QueryNodeError(new MessageImpl( QueryParserMessages.NODE_ACTION_NOT_SUPPORTED, "query", "null")); } this.value = value; setLeaf(false); allocate(); add(query); }
/** * Returns the single child which this node boosts. * * @return the single child which this node boosts */ public QueryNode getChild() { List<QueryNode> children = getChildren(); if (children == null || children.size() == 0) { return null; } return children.get(0); }
@Override public CharSequence toQueryString(EscapeQuerySyntax escapeSyntaxParser) { if (getChild() == null) return ""; return getChild().toQueryString(escapeSyntaxParser) + "^" + getValueString(); }
@Override protected QueryNode postProcessNode(QueryNode node) throws QueryNodeException { if (node instanceof FieldableNode && (node.getParent() == null || !(node.getParent() instanceof FieldableNode))) { FieldableNode fieldNode = (FieldableNode) node; QueryConfigHandler config = getQueryConfigHandler(); if (config != null) { CharSequence field = fieldNode.getField(); FieldConfig fieldConfig = config.getFieldConfig(StringUtils.toString(field)); if (fieldConfig != null) { Float boost = fieldConfig.get(ConfigurationKeys.BOOST); if (boost != null) { return new BoostQueryNode(node, boost); } } } } return node; }
@Override protected QueryNode postProcessNode(QueryNode node) throws QueryNodeException { if (node instanceof FieldableNode && (node.getParent() == null || !(node.getParent() instanceof FieldableNode))) { FieldableNode fieldNode = (FieldableNode) node; QueryConfigHandler config = getQueryConfigHandler(); if (config != null) { CharSequence field = fieldNode.getField(); FieldConfig fieldConfig = config.getFieldConfig(StringUtils.toString(field)); if (fieldConfig != null) { Float boost = fieldConfig.get(ConfigurationKeys.BOOST); if (boost != null) { return new BoostQueryNode(node, boost); } } } } return node; }
@Override public CharSequence toQueryString(EscapeQuerySyntax escapeSyntaxParser) { if (getChild() == null) return ""; return getChild().toQueryString(escapeSyntaxParser) + "^" + getValueString(); }
q = new BoostQueryNode(q, f);
public Query build(final QueryNode queryNode) throws QueryNodeException { final BoostQueryNode boostNode = (BoostQueryNode) queryNode; final QueryNode child = boostNode.getChild(); if (child == null) { return null; } final Query query = (Query) child.getTag(QueryTreeBuilder.QUERY_TREE_BUILDER_TAGID); query.setBoost(boostNode.getValue()); return query; }
@Override public String toString() { return "<boost value='" + getValueString() + "'>" + "\n" + getChild().toString() + "\n</boost>"; }
/** * Constructs a boost node * * @param query * the query to be boosted * @param value * the boost value, it may vary from 0.0 to 1.0 */ public BoostQueryNode(QueryNode query, float value) { if (query == null) { throw new QueryNodeError(new MessageImpl( QueryParserMessages.NODE_ACTION_NOT_SUPPORTED, "query", "null")); } this.value = value; setLeaf(false); allocate(); add(query); }
/** * Returns the single child which this node boosts. * * @return the single child which this node boosts */ public QueryNode getChild() { List<QueryNode> children = getChildren(); if (children == null || children.size() == 0) { return null; } return children.get(0); }
q = new BoostQueryNode(q, f);
@Override public Query build(QueryNode queryNode) throws QueryNodeException { BoostQueryNode boostNode = (BoostQueryNode) queryNode; QueryNode child = boostNode.getChild(); if (child == null) { return null; } Query query = (Query) child .getTag(QueryTreeBuilder.QUERY_TREE_BUILDER_TAGID); return new BoostQuery(query, boostNode.getValue()); }
@Override public String toString() { return "<boost value='" + getValueString() + "'>" + "\n" + getChild().toString() + "\n</boost>"; }
q = new BoostQueryNode(q, f);
@Override public Query build(QueryNode queryNode) throws QueryNodeException { BoostQueryNode boostNode = (BoostQueryNode) queryNode; QueryNode child = boostNode.getChild(); if (child == null) { return null; } Query query = (Query) child .getTag(QueryTreeBuilder.QUERY_TREE_BUILDER_TAGID); return new BoostQuery(query, boostNode.getValue()); }
q = new BoostQueryNode(q, f);
q = new BoostQueryNode(q, f);