Index: modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/config/package.html =================================================================== --- modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/config/package.html (revision 1159937) +++ modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/config/package.html (working copy) @@ -35,7 +35,7 @@

The {@link org.apache.lucene.queryparser.flexible.core.config.QueryConfigHandler} and {@link org.apache.lucene.queryparser.flexible.core.config.FieldConfig} are used in the processors to access config information in a flexible and independent way. -See {@link org.apache.lucene.queryparser.flexible.standard.processors.ParametricRangeQueryNodeProcessor} for a +See {@link org.apache.lucene.queryparser.flexible.standard.processors.TermRangeQueryNodeProcessor} for a reference implementation.

Index: modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/nodes/ParametricQueryNode.java =================================================================== --- modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/nodes/ParametricQueryNode.java (revision 1159938) +++ modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/nodes/ParametricQueryNode.java (working copy) @@ -1,106 +0,0 @@ -package org.apache.lucene.queryparser.flexible.core.nodes; - -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import org.apache.lucene.queryparser.flexible.core.parser.EscapeQuerySyntax; - -/** - * A {@link ParametricQueryNode} represents LE, LT, GE, GT, EQ, NE query. - * Example: date >= "2009-10-10" OR price = 200 - */ -public class ParametricQueryNode extends FieldQueryNode { - - private CompareOperator operator; - - public enum CompareOperator { - LE { - @Override - public String toString() { return "<="; } - }, - LT { - @Override - public String toString() { return "<"; } - }, - GE { - @Override - public String toString() { return ">="; } - }, - GT { - @Override - public String toString() { return ">"; } - }, - EQ { - @Override - public String toString() { return "="; } - }, - NE { - @Override - public String toString() { return "!="; } - }; - } - - /** - * @param field - * - field name - * @param comp - * - CompareOperator - * @param value - * - text value - * @param begin - * - position in the query string - * @param end - * - position in the query string - */ - public ParametricQueryNode(CharSequence field, CompareOperator comp, - CharSequence value, int begin, int end) { - super(field, value, begin, end); - this.operator = comp; - setLeaf(true); - } - - public CharSequence getOperand() { - return getText(); - } - - @Override - public CharSequence toQueryString(EscapeQuerySyntax escapeSyntaxParser) { - return this.field + "" + this.operator.toString() + "\"" + this.text + "\""; - } - - @Override - public String toString() { - return ""; - } - - @Override - public ParametricQueryNode cloneTree() throws CloneNotSupportedException { - ParametricQueryNode clone = (ParametricQueryNode) super.cloneTree(); - - clone.operator = this.operator; - - return clone; - } - - /** - * @return the operator - */ - public CompareOperator getOperator() { - return this.operator; - } -} Index: modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/nodes/ParametricRangeQueryNode.java =================================================================== --- modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/nodes/ParametricRangeQueryNode.java (revision 1159938) +++ modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/nodes/ParametricRangeQueryNode.java (working copy) @@ -1,119 +0,0 @@ -package org.apache.lucene.queryparser.flexible.core.nodes; - -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import org.apache.lucene.queryparser.flexible.core.parser.EscapeQuerySyntax; - -import java.util.List; - - -/** - * A {@link ParametricRangeQueryNode} represents LE, LT, GE, GT, EQ, NE query. - * Example: date >= "2009-10-10" OR price = 200 - */ -public class ParametricRangeQueryNode extends QueryNodeImpl implements - FieldableNode { - - public ParametricRangeQueryNode(ParametricQueryNode lowerBound, - ParametricQueryNode upperBound) { - - if (upperBound.getOperator() != ParametricQueryNode.CompareOperator.LE - && upperBound.getOperator() != ParametricQueryNode.CompareOperator.LT) { - throw new IllegalArgumentException("upper bound should have " - + ParametricQueryNode.CompareOperator.LE + " or " + ParametricQueryNode.CompareOperator.LT); - } - - if (lowerBound.getOperator() != ParametricQueryNode.CompareOperator.GE - && lowerBound.getOperator() != ParametricQueryNode.CompareOperator.GT) { - throw new IllegalArgumentException("lower bound should have " - + ParametricQueryNode.CompareOperator.GE + " or " + ParametricQueryNode.CompareOperator.GT); - } - - if (upperBound.getField() != lowerBound.getField() - || (upperBound.getField() != null && !upperBound.getField().equals( - lowerBound.getField()))) { - - throw new IllegalArgumentException( - "lower and upper bounds should have the same field name!"); - - } - - allocate(); - setLeaf(false); - - add(lowerBound); - add(upperBound); - - } - - public ParametricQueryNode getUpperBound() { - return (ParametricQueryNode) getChildren().get(1); - } - - public ParametricQueryNode getLowerBound() { - return (ParametricQueryNode) getChildren().get(0); - } - - public CharSequence toQueryString(EscapeQuerySyntax escapeSyntaxParser) { - return getLowerBound().toQueryString(escapeSyntaxParser) + " AND " - + getUpperBound().toQueryString(escapeSyntaxParser); - } - - public CharSequence getField() { - return getLowerBound().getField(); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("\n\t"); - sb.append(getUpperBound()).append("\n\t"); - sb.append(getLowerBound()).append("\n"); - sb.append("\n"); - - return sb.toString(); - - } - - @Override - public ParametricRangeQueryNode cloneTree() throws CloneNotSupportedException { - ParametricRangeQueryNode clone = (ParametricRangeQueryNode) super - .cloneTree(); - - // nothing to do here - - return clone; - } - - public void setField(CharSequence fieldName) { - List children = getChildren(); - - if (children != null) { - - for (QueryNode child : getChildren()) { - - if (child instanceof FieldableNode) { - ((FieldableNode) child).setField(fieldName); - } - - } - - } - - } - -} Index: modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/nodes/RangeQueryNode.java =================================================================== --- modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/nodes/RangeQueryNode.java (revision 0) +++ modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/nodes/RangeQueryNode.java (revision 0) @@ -0,0 +1,36 @@ +package org.apache.lucene.queryparser.flexible.core.nodes; + +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + /** + * This interface should be implemented by a {@link QueryNode} that represents + * some kind of range query. + * + */ +public interface RangeQueryNode> extends + FieldableNode { + + T getLowerBound(); + + T getUpperBound(); + + boolean isLowerInclusive(); + + boolean isUpperInclusive(); + +} Index: modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/nodes/package.html =================================================================== --- modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/nodes/package.html (revision 1159938) +++ modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/nodes/package.html (working copy) @@ -59,7 +59,7 @@
  • BoostQueryNode - used for boost operator
  • SlopQueryNode - phrase slop
  • FuzzyQueryNode - fuzzy node
  • -
  • ParametricRangeQueryNode - used for parametric field:[low_value TO high_value]
  • +
  • TermRangeQueryNode - used for parametric field:[low_value TO high_value]
  • ProximityQueryNode - used for proximity search
  • NumericRangeQueryNode - used for numeric range search
  • TokenizedPhraseQueryNode - used by tokenizers/lemmatizers/analyzers for phrases/autophrases
  • @@ -72,7 +72,6 @@
  • NumericQueryNode - used for numeric search
  • PathQueryNode - {@link org.apache.lucene.queryparser.flexible.core.nodes.QueryNode} object used with path-like queries
  • OpaqueQueryNode - Used as for part of the query that can be parsed by other parsers. schema/value
  • -
  • ParametricQueryNode - used for parametric field [>=|<=|=|<|>] value
  • PrefixWildcardQueryNode - non-phrase wildcard query
  • QuotedFieldQUeryNode - regular phrase node
  • WildcardQueryNode - non-phrase wildcard query
  • Index: modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/builders/RangeQueryNodeBuilder.java =================================================================== --- modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/builders/RangeQueryNodeBuilder.java (revision 1159937) +++ modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/builders/RangeQueryNodeBuilder.java (working copy) @@ -1,67 +0,0 @@ -package org.apache.lucene.queryparser.flexible.standard.builders; - -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import org.apache.lucene.queryparser.flexible.core.QueryNodeException; -import org.apache.lucene.queryparser.flexible.core.nodes.ParametricQueryNode; -import org.apache.lucene.queryparser.flexible.core.nodes.QueryNode; -import org.apache.lucene.queryparser.flexible.core.nodes.ParametricQueryNode.CompareOperator; -import org.apache.lucene.queryparser.flexible.standard.nodes.RangeQueryNode; -import org.apache.lucene.queryparser.flexible.standard.processors.MultiTermRewriteMethodProcessor; -import org.apache.lucene.search.MultiTermQuery; -import org.apache.lucene.search.TermRangeQuery; - -/** - * Builds a {@link TermRangeQuery} object from a {@link RangeQueryNode} object. - */ -public class RangeQueryNodeBuilder implements StandardQueryBuilder { - - 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 = TermRangeQuery.newStringRange(field, lower.getTextAsString(), upper.getTextAsString(), lowerInclusive, upperInclusive); - - MultiTermQuery.RewriteMethod method = (MultiTermQuery.RewriteMethod)queryNode.getTag(MultiTermRewriteMethodProcessor.TAG_ID); - if (method != null) { - rangeQuery.setRewriteMethod(method); - } - - return rangeQuery; - - } - -} Index: modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/nodes/AbstractRangeQueryNode.java =================================================================== --- modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/nodes/AbstractRangeQueryNode.java (revision 1159937) +++ modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/nodes/AbstractRangeQueryNode.java (working copy) @@ -23,16 +23,18 @@ import org.apache.lucene.queryparser.flexible.core.nodes.FieldableNode; import org.apache.lucene.queryparser.flexible.core.nodes.QueryNode; import org.apache.lucene.queryparser.flexible.core.nodes.QueryNodeImpl; +import org.apache.lucene.queryparser.flexible.core.nodes.RangeQueryNode; import org.apache.lucene.queryparser.flexible.core.parser.EscapeQuerySyntax; import org.apache.lucene.queryparser.flexible.core.util.StringUtils; /** - * This class should be extended by nodes intending to represent range queries. - * - * @param the type of the range query bounds (lower and upper) + * This class should be extended by nodes intending to represent range queries. + * + * @param + * the type of the range query bounds (lower and upper) */ -public abstract class AbstractRangeQueryNode> - extends QueryNodeImpl implements FieldableNode { +public class AbstractRangeQueryNode> + extends QueryNodeImpl implements RangeQueryNode> { private boolean lowerInclusive, upperInclusive; @@ -145,8 +147,9 @@ String lowerField = StringUtils.toString(lower.getField()); String upperField = StringUtils.toString(upper.getField()); - if ((upperField == null && lowerField == null) - || (upperField != null && !upperField.equals(lowerField))) { + if ((upperField != null || lowerField != null) + && ((upperField != null && !upperField.equals(lowerField)) || !lowerField + .equals(upperField))) { throw new IllegalArgumentException( "lower and upper bounds should have the same field name!"); } Index: modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/nodes/RangeQueryNode.java =================================================================== --- modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/nodes/RangeQueryNode.java (revision 1159937) +++ modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/nodes/RangeQueryNode.java (working copy) @@ -1,50 +0,0 @@ -package org.apache.lucene.queryparser.flexible.standard.nodes; - -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import org.apache.lucene.queryparser.flexible.core.nodes.ParametricQueryNode; -import org.apache.lucene.queryparser.flexible.core.nodes.ParametricRangeQueryNode; -import org.apache.lucene.queryparser.flexible.standard.processors.ParametricRangeQueryNodeProcessor; - -/** - * This query node represents a range query. - * - * @see ParametricRangeQueryNodeProcessor - * @see org.apache.lucene.search.TermRangeQuery - */ -public class RangeQueryNode extends ParametricRangeQueryNode { - - /** - * @param lower - * @param upper - */ - public RangeQueryNode(ParametricQueryNode lower, ParametricQueryNode upper) { - super(lower, upper); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("\n\t"); - sb.append(this.getUpperBound()).append("\n\t"); - sb.append(this.getLowerBound()).append("\n"); - sb.append("\n"); - - return sb.toString(); - - } -} Index: modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.java =================================================================== --- modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.java (revision 1159937) +++ modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.java (working copy) @@ -33,13 +33,12 @@ import org.apache.lucene.queryparser.flexible.core.nodes.ModifierQueryNode; import org.apache.lucene.queryparser.flexible.core.nodes.GroupQueryNode; import org.apache.lucene.queryparser.flexible.core.nodes.OrQueryNode; -import org.apache.lucene.queryparser.flexible.core.nodes.ParametricQueryNode; -import org.apache.lucene.queryparser.flexible.core.nodes.ParametricRangeQueryNode; import org.apache.lucene.queryparser.flexible.standard.nodes.RegexpQueryNode; import org.apache.lucene.queryparser.flexible.core.nodes.SlopQueryNode; import org.apache.lucene.queryparser.flexible.core.nodes.QueryNode; import org.apache.lucene.queryparser.flexible.core.nodes.QuotedFieldQueryNode; import org.apache.lucene.queryparser.flexible.core.parser.SyntaxParser; +import org.apache.lucene.queryparser.flexible.standard.nodes.TermRangeQueryNode; public class StandardSyntaxParser implements SyntaxParser, StandardSyntaxParserConstants { @@ -309,7 +308,8 @@ final public QueryNode Clause(CharSequence field) throws ParseException { QueryNode q; Token fieldToken=null, boost=null, operator=null, term=null; - ParametricQueryNode qLower, qUpper; + FieldQueryNode qLower, qUpper; + boolean lowerInclusive, upperInclusive; boolean group = false; if (jj_2_2(3)) { @@ -375,33 +375,46 @@ } switch (operator.kind) { case OP_LESSTHAN: - qLower = new ParametricQueryNode(field, ParametricQueryNode.CompareOperator.GE, + lowerInclusive = true; + upperInclusive = false; + + qLower = new FieldQueryNode(field, "*", term.beginColumn, term.endColumn); - qUpper = new ParametricQueryNode(field, ParametricQueryNode.CompareOperator.LT, - EscapeQuerySyntaxImpl.discardEscapeChar(term.image), term.beginColumn, term.endColumn); + qUpper = new FieldQueryNode(field, + EscapeQuerySyntaxImpl.discardEscapeChar(term.image), term.beginColumn, term.endColumn); + break; case OP_LESSTHANEQ: - qLower = new ParametricQueryNode(field, ParametricQueryNode.CompareOperator.GE, + lowerInclusive = true; + upperInclusive = true; + + qLower = new FieldQueryNode(field, "*", term.beginColumn, term.endColumn); - qUpper = new ParametricQueryNode(field, ParametricQueryNode.CompareOperator.LE, + qUpper = new FieldQueryNode(field, EscapeQuerySyntaxImpl.discardEscapeChar(term.image), term.beginColumn, term.endColumn); break; case OP_MORETHAN: - qLower = new ParametricQueryNode(field, ParametricQueryNode.CompareOperator.GT, + lowerInclusive = false; + upperInclusive = true; + + qLower = new FieldQueryNode(field, EscapeQuerySyntaxImpl.discardEscapeChar(term.image), term.beginColumn, term.endColumn); - qUpper = new ParametricQueryNode(field, ParametricQueryNode.CompareOperator.LE, + qUpper = new FieldQueryNode(field, "*", term.beginColumn, term.endColumn); break; case OP_MORETHANEQ: - qLower = new ParametricQueryNode(field, ParametricQueryNode.CompareOperator.GE, + lowerInclusive = true; + upperInclusive = true; + + qLower = new FieldQueryNode(field, EscapeQuerySyntaxImpl.discardEscapeChar(term.image), term.beginColumn, term.endColumn); - qUpper = new ParametricQueryNode(field, ParametricQueryNode.CompareOperator.LE, + qUpper = new FieldQueryNode(field, "*", term.beginColumn, term.endColumn); break; default: {if (true) throw new Error("Unhandled case: operator="+operator.toString());} } - q = new ParametricRangeQueryNode(qLower, qUpper); + q = new TermRangeQueryNode(qLower, qUpper, lowerInclusive, upperInclusive); break; default: jj_la1[10] = jj_gen; @@ -497,7 +510,7 @@ boolean startInc=false; boolean endInc=false; QueryNode q =null; - ParametricQueryNode qLower, qUpper; + FieldQueryNode qLower, qUpper; float defaultMinSimilarity = org.apache.lucene.search.FuzzyQuery.defaultMinSimilarity; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case TERM: @@ -638,11 +651,11 @@ goop2.image = goop2.image.substring(1, goop2.image.length()-1); } - qLower = new ParametricQueryNode(field, startInc ? ParametricQueryNode.CompareOperator.GE : ParametricQueryNode.CompareOperator.GT, + qLower = new FieldQueryNode(field, EscapeQuerySyntaxImpl.discardEscapeChar(goop1.image), goop1.beginColumn, goop1.endColumn); - qUpper = new ParametricQueryNode(field, endInc ? ParametricQueryNode.CompareOperator.LE : ParametricQueryNode.CompareOperator.LT, + qUpper = new FieldQueryNode(field, EscapeQuerySyntaxImpl.discardEscapeChar(goop2.image), goop2.beginColumn, goop2.endColumn); - q = new ParametricRangeQueryNode(qLower, qUpper); + q = new TermRangeQueryNode(qLower, qUpper, startInc ? true : false, endInc ? true : false); break; case QUOTED: term = jj_consume_token(QUOTED); @@ -726,8 +739,16 @@ return false; } - private boolean jj_3R_10() { - if (jj_scan_token(TERM)) return true; + private boolean jj_3R_6() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_7()) { + jj_scanpos = xsp; + if (jj_3R_8()) { + jj_scanpos = xsp; + if (jj_3R_9()) return true; + } + } return false; } @@ -742,6 +763,11 @@ return false; } + private boolean jj_3R_10() { + if (jj_scan_token(TERM)) return true; + return false; + } + private boolean jj_3R_12() { if (jj_scan_token(RANGEIN_START)) return true; return false; @@ -786,24 +812,6 @@ return false; } - private boolean jj_3R_9() { - if (jj_scan_token(QUOTED)) return true; - return false; - } - - private boolean jj_3R_6() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_7()) { - jj_scanpos = xsp; - if (jj_3R_8()) { - jj_scanpos = xsp; - if (jj_3R_9()) return true; - } - } - return false; - } - private boolean jj_3R_5() { Token xsp; xsp = jj_scanpos; @@ -828,6 +836,11 @@ return false; } + private boolean jj_3R_9() { + if (jj_scan_token(QUOTED)) return true; + return false; + } + /** Generated Token Manager. */ public StandardSyntaxParserTokenManager token_source; JavaCharStream jj_input_stream; Index: modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.jj =================================================================== --- modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.jj (revision 1159937) +++ modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.jj (working copy) @@ -45,13 +45,12 @@ import org.apache.lucene.queryparser.flexible.core.nodes.ModifierQueryNode; import org.apache.lucene.queryparser.flexible.core.nodes.GroupQueryNode; import org.apache.lucene.queryparser.flexible.core.nodes.OrQueryNode; -import org.apache.lucene.queryparser.flexible.core.nodes.ParametricQueryNode; -import org.apache.lucene.queryparser.flexible.core.nodes.ParametricRangeQueryNode; import org.apache.lucene.queryparser.flexible.standard.nodes.RegexpQueryNode; import org.apache.lucene.queryparser.flexible.core.nodes.SlopQueryNode; import org.apache.lucene.queryparser.flexible.core.nodes.QueryNode; import org.apache.lucene.queryparser.flexible.core.nodes.QuotedFieldQueryNode; import org.apache.lucene.queryparser.flexible.core.parser.SyntaxParser; +import org.apache.lucene.queryparser.flexible.standard.nodes.TermRangeQueryNode; public class StandardSyntaxParser implements SyntaxParser { @@ -328,7 +327,8 @@ QueryNode Clause(CharSequence field) : { QueryNode q; Token fieldToken=null, boost=null, operator=null, term=null; - ParametricQueryNode qLower, qUpper; + FieldQueryNode qLower, qUpper; + boolean lowerInclusive, upperInclusive; boolean group = false; } @@ -344,33 +344,46 @@ } switch (operator.kind) { case OP_LESSTHAN: - qLower = new ParametricQueryNode(field, ParametricQueryNode.CompareOperator.GE, + lowerInclusive = true; + upperInclusive = false; + + qLower = new FieldQueryNode(field, "*", term.beginColumn, term.endColumn); - qUpper = new ParametricQueryNode(field, ParametricQueryNode.CompareOperator.LT, - EscapeQuerySyntaxImpl.discardEscapeChar(term.image), term.beginColumn, term.endColumn); + qUpper = new FieldQueryNode(field, + EscapeQuerySyntaxImpl.discardEscapeChar(term.image), term.beginColumn, term.endColumn); + break; case OP_LESSTHANEQ: - qLower = new ParametricQueryNode(field, ParametricQueryNode.CompareOperator.GE, + lowerInclusive = true; + upperInclusive = true; + + qLower = new FieldQueryNode(field, "*", term.beginColumn, term.endColumn); - qUpper = new ParametricQueryNode(field, ParametricQueryNode.CompareOperator.LE, + qUpper = new FieldQueryNode(field, EscapeQuerySyntaxImpl.discardEscapeChar(term.image), term.beginColumn, term.endColumn); break; case OP_MORETHAN: - qLower = new ParametricQueryNode(field, ParametricQueryNode.CompareOperator.GT, + lowerInclusive = false; + upperInclusive = true; + + qLower = new FieldQueryNode(field, EscapeQuerySyntaxImpl.discardEscapeChar(term.image), term.beginColumn, term.endColumn); - qUpper = new ParametricQueryNode(field, ParametricQueryNode.CompareOperator.LE, + qUpper = new FieldQueryNode(field, "*", term.beginColumn, term.endColumn); break; case OP_MORETHANEQ: - qLower = new ParametricQueryNode(field, ParametricQueryNode.CompareOperator.GE, + lowerInclusive = true; + upperInclusive = true; + + qLower = new FieldQueryNode(field, EscapeQuerySyntaxImpl.discardEscapeChar(term.image), term.beginColumn, term.endColumn); - qUpper = new ParametricQueryNode(field, ParametricQueryNode.CompareOperator.LE, + qUpper = new FieldQueryNode(field, "*", term.beginColumn, term.endColumn); break; default: throw new Error("Unhandled case: operator="+operator.toString()); } - q = new ParametricRangeQueryNode(qLower, qUpper); + q = new TermRangeQueryNode(qLower, qUpper, lowerInclusive, upperInclusive); } ) | [ @@ -411,7 +424,7 @@ boolean startInc=false; boolean endInc=false; QueryNode q =null; - ParametricQueryNode qLower, qUpper; + FieldQueryNode qLower, qUpper; float defaultMinSimilarity = org.apache.lucene.search.FuzzyQuery.defaultMinSimilarity; } { @@ -453,11 +466,11 @@ goop2.image = goop2.image.substring(1, goop2.image.length()-1); } - qLower = new ParametricQueryNode(field, startInc ? ParametricQueryNode.CompareOperator.GE : ParametricQueryNode.CompareOperator.GT, + qLower = new FieldQueryNode(field, EscapeQuerySyntaxImpl.discardEscapeChar(goop1.image), goop1.beginColumn, goop1.endColumn); - qUpper = new ParametricQueryNode(field, endInc ? ParametricQueryNode.CompareOperator.LE : ParametricQueryNode.CompareOperator.LT, + qUpper = new FieldQueryNode(field, EscapeQuerySyntaxImpl.discardEscapeChar(goop2.image), goop2.beginColumn, goop2.endColumn); - q = new ParametricRangeQueryNode(qLower, qUpper); + q = new TermRangeQueryNode(qLower, qUpper, startInc ? true : false, endInc ? true : false); } | term= {q = new QuotedFieldQueryNode(field, EscapeQuerySyntaxImpl.discardEscapeChar(term.image.substring(1, term.image.length()-1)), term.beginColumn + 1, term.endColumn - 1);} [ fuzzySlop= ] Index: modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParserTokenManager.java =================================================================== --- modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParserTokenManager.java (revision 1159937) +++ modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParserTokenManager.java (working copy) @@ -31,13 +31,12 @@ import org.apache.lucene.queryparser.flexible.core.nodes.ModifierQueryNode; import org.apache.lucene.queryparser.flexible.core.nodes.GroupQueryNode; import org.apache.lucene.queryparser.flexible.core.nodes.OrQueryNode; -import org.apache.lucene.queryparser.flexible.core.nodes.ParametricQueryNode; -import org.apache.lucene.queryparser.flexible.core.nodes.ParametricRangeQueryNode; import org.apache.lucene.queryparser.flexible.standard.nodes.RegexpQueryNode; import org.apache.lucene.queryparser.flexible.core.nodes.SlopQueryNode; import org.apache.lucene.queryparser.flexible.core.nodes.QueryNode; import org.apache.lucene.queryparser.flexible.core.nodes.QuotedFieldQueryNode; import org.apache.lucene.queryparser.flexible.core.parser.SyntaxParser; +import org.apache.lucene.queryparser.flexible.standard.nodes.TermRangeQueryNode; /** Token Manager. */ public class StandardSyntaxParserTokenManager implements StandardSyntaxParserConstants Index: modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/AnalyzerQueryNodeProcessor.java =================================================================== --- modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/AnalyzerQueryNodeProcessor.java (revision 1159937) +++ modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/AnalyzerQueryNodeProcessor.java (working copy) @@ -34,9 +34,9 @@ import org.apache.lucene.queryparser.flexible.core.nodes.FuzzyQueryNode; import org.apache.lucene.queryparser.flexible.core.nodes.GroupQueryNode; import org.apache.lucene.queryparser.flexible.core.nodes.NoTokenFoundQueryNode; -import org.apache.lucene.queryparser.flexible.core.nodes.ParametricQueryNode; import org.apache.lucene.queryparser.flexible.core.nodes.QueryNode; import org.apache.lucene.queryparser.flexible.core.nodes.QuotedFieldQueryNode; +import org.apache.lucene.queryparser.flexible.core.nodes.RangeQueryNode; import org.apache.lucene.queryparser.flexible.core.nodes.TextableQueryNode; import org.apache.lucene.queryparser.flexible.core.nodes.TokenizedPhraseQueryNode; import org.apache.lucene.queryparser.flexible.core.processors.QueryNodeProcessorImpl; @@ -50,7 +50,7 @@ * is defined in the {@link QueryConfigHandler}. If it is and the analyzer is * not null, it looks for every {@link FieldQueryNode} that is not * {@link WildcardQueryNode}, {@link FuzzyQueryNode} or - * {@link ParametricQueryNode} contained in the query node tree, then it applies + * {@link RangeQueryNode} contained in the query node tree, then it applies * the analyzer to that {@link FieldQueryNode} object.
    *
    * If the analyzer return only one term, the returned term is set to the @@ -106,7 +106,7 @@ if (node instanceof TextableQueryNode && !(node instanceof WildcardQueryNode) && !(node instanceof FuzzyQueryNode) - && !(node instanceof ParametricQueryNode)) { + && !(node.getParent() instanceof RangeQueryNode)) { FieldQueryNode fieldNode = ((FieldQueryNode) node); String text = fieldNode.getTextAsString(); Index: modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/LowercaseExpandedTermsQueryNodeProcessor.java =================================================================== --- modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/LowercaseExpandedTermsQueryNodeProcessor.java (revision 1159937) +++ modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/LowercaseExpandedTermsQueryNodeProcessor.java (working copy) @@ -21,9 +21,10 @@ import org.apache.lucene.queryparser.flexible.core.QueryNodeException; import org.apache.lucene.queryparser.flexible.core.config.QueryConfigHandler; +import org.apache.lucene.queryparser.flexible.core.nodes.FieldQueryNode; import org.apache.lucene.queryparser.flexible.core.nodes.FuzzyQueryNode; -import org.apache.lucene.queryparser.flexible.core.nodes.ParametricQueryNode; import org.apache.lucene.queryparser.flexible.core.nodes.QueryNode; +import org.apache.lucene.queryparser.flexible.core.nodes.RangeQueryNode; import org.apache.lucene.queryparser.flexible.core.nodes.TextableQueryNode; import org.apache.lucene.queryparser.flexible.core.processors.QueryNodeProcessorImpl; import org.apache.lucene.queryparser.flexible.core.util.UnescapedCharSequence; @@ -36,7 +37,7 @@ * {@link ConfigurationKeys#LOWERCASE_EXPANDED_TERMS} is defined in the * {@link QueryConfigHandler}. If it is and the expanded terms should be * lower-cased, it looks for every {@link WildcardQueryNode}, - * {@link FuzzyQueryNode} and {@link ParametricQueryNode} and lower-case its + * {@link FuzzyQueryNode} and children of a {@link RangeQueryNode} and lower-case its * term.
    * * @see ConfigurationKeys#LOWERCASE_EXPANDED_TERMS @@ -63,8 +64,10 @@ @Override protected QueryNode postProcessNode(QueryNode node) throws QueryNodeException { - if (node instanceof WildcardQueryNode || node instanceof FuzzyQueryNode - || node instanceof ParametricQueryNode || node instanceof RegexpQueryNode) { + if (node instanceof WildcardQueryNode + || node instanceof FuzzyQueryNode + || (node instanceof FieldQueryNode && node.getParent() instanceof RangeQueryNode) + || node instanceof RegexpQueryNode) { TextableQueryNode txtNode = (TextableQueryNode) node; CharSequence text = txtNode.getText(); Index: modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/NumericQueryNodeProcessor.java =================================================================== --- modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/NumericQueryNodeProcessor.java (revision 1159937) +++ modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/NumericQueryNodeProcessor.java (working copy) @@ -28,9 +28,8 @@ import org.apache.lucene.queryparser.flexible.core.config.QueryConfigHandler; import org.apache.lucene.queryparser.flexible.core.messages.QueryParserMessages; import org.apache.lucene.queryparser.flexible.core.nodes.FieldQueryNode; -import org.apache.lucene.queryparser.flexible.core.nodes.ParametricQueryNode; -import org.apache.lucene.queryparser.flexible.core.nodes.ParametricRangeQueryNode; import org.apache.lucene.queryparser.flexible.core.nodes.QueryNode; +import org.apache.lucene.queryparser.flexible.core.nodes.RangeQueryNode; import org.apache.lucene.queryparser.flexible.core.processors.QueryNodeProcessorImpl; import org.apache.lucene.queryparser.flexible.standard.config.NumericConfig; import org.apache.lucene.queryparser.flexible.standard.config.StandardQueryConfigHandler.ConfigurationKeys; @@ -46,11 +45,11 @@ * {@link FieldQueryNode} to be a numeric query and convert it to * {@link NumericRangeQueryNode} with upper and lower inclusive and lower and * upper equals to the value represented by the {@link FieldQueryNode} converted - * to {@link Number}. It means that field:1 is converted to field:[1 TO - * 1].
    + * to {@link Number}. It means that field:1 is converted to field:[1 + * TO 1].
    *
    - * Note that {@link ParametricQueryNode}s are ignored, even being a - * {@link FieldQueryNode}. + * Note that {@link FieldQueryNode}s children of a + * {@link RangeQueryNode} are ignored. * * @see ConfigurationKeys#NUMERIC_CONFIG * @see FieldQueryNode @@ -70,7 +69,7 @@ protected QueryNode postProcessNode(QueryNode node) throws QueryNodeException { if (node instanceof FieldQueryNode - && !(node.getParent() instanceof ParametricRangeQueryNode)) { + && !(node.getParent() instanceof RangeQueryNode)) { QueryConfigHandler config = getQueryConfigHandler(); Index: modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/NumericRangeQueryNodeProcessor.java =================================================================== --- modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/NumericRangeQueryNodeProcessor.java (revision 1159937) +++ modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/NumericRangeQueryNodeProcessor.java (working copy) @@ -27,28 +27,27 @@ import org.apache.lucene.queryparser.flexible.core.config.FieldConfig; import org.apache.lucene.queryparser.flexible.core.config.QueryConfigHandler; import org.apache.lucene.queryparser.flexible.core.messages.QueryParserMessages; -import org.apache.lucene.queryparser.flexible.core.nodes.ParametricQueryNode; -import org.apache.lucene.queryparser.flexible.core.nodes.ParametricRangeQueryNode; +import org.apache.lucene.queryparser.flexible.core.nodes.FieldQueryNode; import org.apache.lucene.queryparser.flexible.core.nodes.QueryNode; -import org.apache.lucene.queryparser.flexible.core.nodes.ParametricQueryNode.CompareOperator; import org.apache.lucene.queryparser.flexible.core.processors.QueryNodeProcessorImpl; import org.apache.lucene.queryparser.flexible.core.util.StringUtils; import org.apache.lucene.queryparser.flexible.standard.config.NumericConfig; import org.apache.lucene.queryparser.flexible.standard.config.StandardQueryConfigHandler.ConfigurationKeys; import org.apache.lucene.queryparser.flexible.standard.nodes.NumericQueryNode; import org.apache.lucene.queryparser.flexible.standard.nodes.NumericRangeQueryNode; +import org.apache.lucene.queryparser.flexible.standard.nodes.TermRangeQueryNode; /** - * This processor is used to convert {@link ParametricRangeQueryNode}s to + * This processor is used to convert {@link TermRangeQueryNode}s to * {@link NumericRangeQueryNode}s. It looks for * {@link ConfigurationKeys#NUMERIC_CONFIG} set in the {@link FieldConfig} of - * every {@link ParametricRangeQueryNode} found. If + * every {@link TermRangeQueryNode} found. If * {@link ConfigurationKeys#NUMERIC_CONFIG} is found, it considers that - * {@link ParametricRangeQueryNode} to be a numeric range query and convert it to + * {@link TermRangeQueryNode} to be a numeric range query and convert it to * {@link NumericRangeQueryNode}. * * @see ConfigurationKeys#NUMERIC_CONFIG - * @see ParametricRangeQueryNode + * @see TermRangeQueryNode * @see NumericConfig * @see NumericRangeQueryNode */ @@ -64,13 +63,13 @@ @Override protected QueryNode postProcessNode(QueryNode node) throws QueryNodeException { - if (node instanceof ParametricRangeQueryNode) { + if (node instanceof TermRangeQueryNode) { QueryConfigHandler config = getQueryConfigHandler(); if (config != null) { - ParametricRangeQueryNode parametricRangeNode = (ParametricRangeQueryNode) node; + TermRangeQueryNode termRangeNode = (TermRangeQueryNode) node; FieldConfig fieldConfig = config.getFieldConfig(StringUtils - .toString(parametricRangeNode.getField())); + .toString(termRangeNode.getField())); if (fieldConfig != null) { @@ -79,8 +78,8 @@ if (numericConfig != null) { - ParametricQueryNode lower = parametricRangeNode.getLowerBound(); - ParametricQueryNode upper = parametricRangeNode.getUpperBound(); + FieldQueryNode lower = termRangeNode.getLowerBound(); + FieldQueryNode upper = termRangeNode.getUpperBound(); String lowerText = lower.getTextAsString(); String upperText = upper.getTextAsString(); @@ -134,14 +133,12 @@ } NumericQueryNode lowerNode = new NumericQueryNode( - parametricRangeNode.getField(), lowerNumber, numberFormat); + termRangeNode.getField(), lowerNumber, numberFormat); NumericQueryNode upperNode = new NumericQueryNode( - parametricRangeNode.getField(), upperNumber, numberFormat); + termRangeNode.getField(), upperNumber, numberFormat); - boolean upperInclusive = upper == null - | upper.getOperator() == CompareOperator.LE; - boolean lowerInclusive = lower == null - | lower.getOperator() == CompareOperator.GE; + boolean lowerInclusive = termRangeNode.isLowerInclusive(); + boolean upperInclusive = termRangeNode.isUpperInclusive(); return new NumericRangeQueryNode(lowerNode, upperNode, lowerInclusive, upperInclusive, numericConfig); Index: modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/OpenRangeQueryNodeProcessor.java =================================================================== --- modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/OpenRangeQueryNodeProcessor.java (revision 1159937) +++ modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/OpenRangeQueryNodeProcessor.java (working copy) @@ -3,11 +3,11 @@ import java.util.List; import org.apache.lucene.queryparser.flexible.core.QueryNodeException; -import org.apache.lucene.queryparser.flexible.core.nodes.ParametricQueryNode; -import org.apache.lucene.queryparser.flexible.core.nodes.ParametricRangeQueryNode; +import org.apache.lucene.queryparser.flexible.core.nodes.FieldQueryNode; import org.apache.lucene.queryparser.flexible.core.nodes.QueryNode; import org.apache.lucene.queryparser.flexible.core.processors.QueryNodeProcessorImpl; import org.apache.lucene.queryparser.flexible.core.util.UnescapedCharSequence; +import org.apache.lucene.queryparser.flexible.standard.nodes.TermRangeQueryNode; public class OpenRangeQueryNodeProcessor extends QueryNodeProcessorImpl { @@ -18,10 +18,10 @@ @Override protected QueryNode postProcessNode(QueryNode node) throws QueryNodeException { - if (node instanceof ParametricRangeQueryNode) { - ParametricRangeQueryNode rangeNode = (ParametricRangeQueryNode) node; - ParametricQueryNode lowerNode = (ParametricQueryNode) rangeNode.getLowerBound(); - ParametricQueryNode upperNode = (ParametricQueryNode) rangeNode.getUpperBound(); + if (node instanceof TermRangeQueryNode) { + TermRangeQueryNode rangeNode = (TermRangeQueryNode) node; + FieldQueryNode lowerNode = (FieldQueryNode) rangeNode.getLowerBound(); + FieldQueryNode upperNode = (FieldQueryNode) rangeNode.getUpperBound(); CharSequence lowerText = lowerNode.getText(); CharSequence upperText = upperNode.getText(); Index: modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/ParametricRangeQueryNodeProcessor.java =================================================================== --- modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/ParametricRangeQueryNodeProcessor.java (revision 1159937) +++ modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/ParametricRangeQueryNodeProcessor.java (working copy) @@ -1,164 +0,0 @@ -package org.apache.lucene.queryparser.flexible.standard.processors; - -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import java.text.DateFormat; -import java.util.Calendar; -import java.util.Date; -import java.util.List; -import java.util.Locale; - -import org.apache.lucene.document.DateTools; -import org.apache.lucene.document.DateTools.Resolution; -import org.apache.lucene.queryparser.flexible.core.QueryNodeException; -import org.apache.lucene.queryparser.flexible.core.config.FieldConfig; -import org.apache.lucene.queryparser.flexible.core.config.QueryConfigHandler; -import org.apache.lucene.queryparser.flexible.core.nodes.ParametricQueryNode; -import org.apache.lucene.queryparser.flexible.core.nodes.ParametricRangeQueryNode; -import org.apache.lucene.queryparser.flexible.core.nodes.QueryNode; -import org.apache.lucene.queryparser.flexible.core.nodes.ParametricQueryNode.CompareOperator; -import org.apache.lucene.queryparser.flexible.core.processors.QueryNodeProcessorImpl; -import org.apache.lucene.queryparser.flexible.standard.config.StandardQueryConfigHandler.ConfigurationKeys; -import org.apache.lucene.queryparser.flexible.standard.nodes.TermRangeQueryNode; - -/** - * This processor converts {@link ParametricRangeQueryNode} objects to - * {@link TermRangeQueryNode} objects. It reads the lower and upper bounds value - * from the {@link ParametricRangeQueryNode} object and try to parse their - * values using a {@link DateFormat}. If the values cannot be parsed to a date - * value, it will only create the {@link TermRangeQueryNode} using the - * non-parsed values.
    - *
    - * If a {@link ConfigurationKeys#LOCALE} is defined in the - * {@link QueryConfigHandler} it will be used to parse the date, otherwise - * {@link Locale#getDefault()} will be used.
    - *
    - * If a {@link ConfigurationKeys#DATE_RESOLUTION} is defined and the - * {@link Resolution} is not null it will also be used to parse the - * date value.
    - *
    - * - * @see ConfigurationKeys#DATE_RESOLUTION - * @see ConfigurationKeys#LOCALE - * @see TermRangeQueryNode - * @see ParametricRangeQueryNode - */ -public class ParametricRangeQueryNodeProcessor extends QueryNodeProcessorImpl { - - public ParametricRangeQueryNodeProcessor() { - // empty constructor - } - - @Override - protected QueryNode postProcessNode(QueryNode node) throws QueryNodeException { - - if (node instanceof ParametricRangeQueryNode) { - ParametricRangeQueryNode parametricRangeNode = (ParametricRangeQueryNode) node; - ParametricQueryNode upper = parametricRangeNode.getUpperBound(); - ParametricQueryNode lower = parametricRangeNode.getLowerBound(); - - DateTools.Resolution dateRes = null; - boolean inclusive = false; - Locale locale = getQueryConfigHandler().get(ConfigurationKeys.LOCALE); - - if (locale == null) { - locale = Locale.getDefault(); - } - - CharSequence field = parametricRangeNode.getField(); - String fieldStr = null; - - if (field != null) { - fieldStr = field.toString(); - } - - FieldConfig fieldConfig = getQueryConfigHandler() - .getFieldConfig(fieldStr); - - if (fieldConfig != null) { - dateRes = fieldConfig.get(ConfigurationKeys.DATE_RESOLUTION); - } - - if (upper.getOperator() == CompareOperator.LE) { - inclusive = true; - } - - String part1 = lower.getTextAsString(); - String part2 = upper.getTextAsString(); - - try { - DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, locale); - df.setLenient(true); - - if (part1.length() > 0) { - Date d1 = df.parse(part1); - part1 = DateTools.dateToString(d1, dateRes); - lower.setText(part1); - } - - if (part2.length() > 0) { - Date d2 = df.parse(part2); - if (inclusive) { - // The user can only specify the date, not the time, so make sure - // the time is set to the latest possible time of that date to - // really - // include all documents: - Calendar cal = Calendar.getInstance(locale); - cal.setTime(d2); - cal.set(Calendar.HOUR_OF_DAY, 23); - cal.set(Calendar.MINUTE, 59); - cal.set(Calendar.SECOND, 59); - cal.set(Calendar.MILLISECOND, 999); - d2 = cal.getTime(); - } - - part2 = DateTools.dateToString(d2, dateRes); - upper.setText(part2); - - } - - } catch (Exception e) { - // do nothing - } - - return new TermRangeQueryNode(lower, upper, part1.length() == 0 - | lower.getOperator() == CompareOperator.GE, part2.length() == 0 - | upper.getOperator() == CompareOperator.LE); - - } - - return node; - - } - - @Override - protected QueryNode preProcessNode(QueryNode node) throws QueryNodeException { - - return node; - - } - - @Override - protected List setChildrenOrder(List children) - throws QueryNodeException { - - return children; - - } - -} Index: modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/StandardQueryNodeProcessorPipeline.java =================================================================== --- modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/StandardQueryNodeProcessorPipeline.java (revision 1159937) +++ modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/StandardQueryNodeProcessorPipeline.java (working copy) @@ -56,7 +56,7 @@ add(new NumericQueryNodeProcessor()); add(new NumericRangeQueryNodeProcessor()); add(new LowercaseExpandedTermsQueryNodeProcessor()); - add(new ParametricRangeQueryNodeProcessor()); + add(new TermRangeQueryNodeProcessor()); add(new AllowLeadingWildcardProcessor()); add(new AnalyzerQueryNodeProcessor()); add(new PhraseSlopQueryNodeProcessor()); Index: modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/TermRangeQueryNodeProcessor.java =================================================================== --- modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/TermRangeQueryNodeProcessor.java (revision 1159937) +++ modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/TermRangeQueryNodeProcessor.java (working copy) @@ -28,21 +28,18 @@ import org.apache.lucene.queryparser.flexible.core.QueryNodeException; import org.apache.lucene.queryparser.flexible.core.config.FieldConfig; import org.apache.lucene.queryparser.flexible.core.config.QueryConfigHandler; -import org.apache.lucene.queryparser.flexible.core.nodes.ParametricQueryNode; -import org.apache.lucene.queryparser.flexible.core.nodes.ParametricRangeQueryNode; +import org.apache.lucene.queryparser.flexible.core.nodes.FieldQueryNode; import org.apache.lucene.queryparser.flexible.core.nodes.QueryNode; -import org.apache.lucene.queryparser.flexible.core.nodes.ParametricQueryNode.CompareOperator; import org.apache.lucene.queryparser.flexible.core.processors.QueryNodeProcessorImpl; import org.apache.lucene.queryparser.flexible.standard.config.StandardQueryConfigHandler.ConfigurationKeys; import org.apache.lucene.queryparser.flexible.standard.nodes.TermRangeQueryNode; /** - * This processor converts {@link ParametricRangeQueryNode} objects to - * {@link TermRangeQueryNode} objects. It reads the lower and upper bounds value - * from the {@link ParametricRangeQueryNode} object and try to parse their - * values using a {@link DateFormat}. If the values cannot be parsed to a date - * value, it will only create the {@link TermRangeQueryNode} using the - * non-parsed values.
    + * This processors process {@link TermRangeQueryNode}s. It reads the lower and + * upper bounds value from the {@link TermRangeQueryNode} object and try + * to parse their values using a {@link DateFormat}. If the values cannot be + * parsed to a date value, it will only create the {@link TermRangeQueryNode} + * using the non-parsed values.
    *
    * If a {@link ConfigurationKeys#LOCALE} is defined in the * {@link QueryConfigHandler} it will be used to parse the date, otherwise @@ -56,21 +53,20 @@ * @see ConfigurationKeys#DATE_RESOLUTION * @see ConfigurationKeys#LOCALE * @see TermRangeQueryNode - * @see ParametricRangeQueryNode */ -public class ParametricRangeQueryNodeProcessor extends QueryNodeProcessorImpl { +public class TermRangeQueryNodeProcessor extends QueryNodeProcessorImpl { - public ParametricRangeQueryNodeProcessor() { + public TermRangeQueryNodeProcessor() { // empty constructor } @Override protected QueryNode postProcessNode(QueryNode node) throws QueryNodeException { - if (node instanceof ParametricRangeQueryNode) { - ParametricRangeQueryNode parametricRangeNode = (ParametricRangeQueryNode) node; - ParametricQueryNode upper = parametricRangeNode.getUpperBound(); - ParametricQueryNode lower = parametricRangeNode.getLowerBound(); + if (node instanceof TermRangeQueryNode) { + TermRangeQueryNode termRangeNode = (TermRangeQueryNode) node; + FieldQueryNode upper = termRangeNode.getUpperBound(); + FieldQueryNode lower = termRangeNode.getLowerBound(); DateTools.Resolution dateRes = null; boolean inclusive = false; @@ -80,7 +76,7 @@ locale = Locale.getDefault(); } - CharSequence field = parametricRangeNode.getField(); + CharSequence field = termRangeNode.getField(); String fieldStr = null; if (field != null) { @@ -94,7 +90,7 @@ dateRes = fieldConfig.get(ConfigurationKeys.DATE_RESOLUTION); } - if (upper.getOperator() == CompareOperator.LE) { + if (termRangeNode.isUpperInclusive()) { inclusive = true; } @@ -136,10 +132,6 @@ // do nothing } - return new TermRangeQueryNode(lower, upper, part1.length() == 0 - | lower.getOperator() == CompareOperator.GE, part2.length() == 0 - | upper.getOperator() == CompareOperator.LE); - } return node; Index: modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/WildcardQueryNodeProcessor.java =================================================================== --- modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/WildcardQueryNodeProcessor.java (revision 1159937) +++ modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/WildcardQueryNodeProcessor.java (working copy) @@ -22,12 +22,12 @@ import org.apache.lucene.queryparser.flexible.core.QueryNodeException; import org.apache.lucene.queryparser.flexible.core.nodes.FieldQueryNode; import org.apache.lucene.queryparser.flexible.core.nodes.FuzzyQueryNode; -import org.apache.lucene.queryparser.flexible.core.nodes.ParametricQueryNode; import org.apache.lucene.queryparser.flexible.core.nodes.QueryNode; import org.apache.lucene.queryparser.flexible.core.nodes.QuotedFieldQueryNode; import org.apache.lucene.queryparser.flexible.core.processors.QueryNodeProcessorImpl; import org.apache.lucene.queryparser.flexible.core.util.UnescapedCharSequence; import org.apache.lucene.queryparser.flexible.standard.nodes.PrefixWildcardQueryNode; +import org.apache.lucene.queryparser.flexible.standard.nodes.TermRangeQueryNode; import org.apache.lucene.queryparser.flexible.standard.nodes.WildcardQueryNode; import org.apache.lucene.queryparser.flexible.standard.parser.StandardSyntaxParser; import org.apache.lucene.search.PrefixQuery; @@ -57,9 +57,9 @@ FieldQueryNode fqn = (FieldQueryNode) node; CharSequence text = fqn.getText(); - // do not process wildcards for ParametricQueryNode and + // do not process wildcards for TermRangeQueryNode children and // QuotedFieldQueryNode to reproduce the old parser behavior - if (fqn instanceof ParametricQueryNode + if (fqn.getParent() instanceof TermRangeQueryNode || fqn instanceof QuotedFieldQueryNode || text.length() <= 0){ // Ignore empty terms