public RangeQueryNodeBuilder() {
// empty constructor
}
public TermRangeQuery build(QueryNode queryNode) throws QueryNodeException {
RangeQueryNode rangeNode = (RangeQueryNode) queryNode;
ParametricQueryNode upper = rangeNode.getUpperBound();
ParametricQueryNode lower = rangeNode.getLowerBound();
boolean lowerInclusive = false;
boolean upperInclusive = false;
if (upper.getOperator() == CompareOperator.LE) {
upperInclusive = true;
}
if (lower.getOperator() == CompareOperator.GE) {
lowerInclusive = true;
}
String field = rangeNode.getField().toString();
TermRangeQuery rangeQuery = new TermRangeQuery(field, lower
.getTextAsString(), upper.getTextAsString(), lowerInclusive,
upperInclusive, rangeNode.getCollator());
MultiTermQuery.RewriteMethod method = (MultiTermQuery.RewriteMethod)queryNode.getTag(MultiTermRewriteMethodAttribute.TAG_ID);
if (method != null) {
rangeQuery.setRewriteMethod(method);
}