Property changes on: .
___________________________________________________________________
Modified: svn:mergeinfo
Merged /lucene/dev/trunk:r1145885,1146984,1150671,1152892
Property changes on: lucene
___________________________________________________________________
Modified: svn:mergeinfo
Merged /lucene/dev/trunk/lucene:r1145885,1146984,1150671,1152892
Property changes on: lucene\backwards
___________________________________________________________________
Modified: svn:mergeinfo
Merged /lucene/dev/trunk/lucene/backwards:r1145885,1146984,1150671,1152892
Property changes on: lucene\backwards\src\test
___________________________________________________________________
Modified: svn:mergeinfo
Merged /lucene/dev/trunk/lucene/backwards/src/test:r1145885,1146984,1150671,1152892
Property changes on: lucene\backwards\src\test-framework
___________________________________________________________________
Modified: svn:mergeinfo
Merged /lucene/dev/trunk/lucene/backwards/src/test-framework:r1145885,1146984,1150671,1152892
Index: lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/messages/QueryParserMessages.java
===================================================================
--- lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/messages/QueryParserMessages.java (revision 1158551)
+++ lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/messages/QueryParserMessages.java (working copy)
@@ -50,5 +50,8 @@
public static String WILDCARD_NOT_SUPPORTED;
public static String TOO_MANY_BOOLEAN_CLAUSES;
public static String LEADING_WILDCARD_NOT_ALLOWED;
+ public static String COULD_NOT_PARSE_NUMBER;
+ public static String NUMBER_CLASS_NOT_SUPPORTED_BY_NUMERIC_RANGE_QUERY;
+ public static String UNSUPPORTED_NUMERIC_DATA_TYPE;
}
Index: lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/nodes/FieldQueryNode.java
===================================================================
--- lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/nodes/FieldQueryNode.java (revision 1158551)
+++ lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/nodes/FieldQueryNode.java (working copy)
@@ -25,8 +25,7 @@
/**
* A {@link FieldQueryNode} represents a element that contains field/text tuple
*/
-public class FieldQueryNode extends QueryNodeImpl implements TextableQueryNode,
- FieldableNode {
+public class FieldQueryNode extends QueryNodeImpl implements FieldValuePairQueryNode, TextableQueryNode {
private static final long serialVersionUID = 3634521145130758265L;
@@ -182,4 +181,12 @@
}
+ public CharSequence getValue() {
+ return getText();
+ }
+
+ public void setValue(CharSequence value) {
+ setText(value);
+ }
+
}
Index: lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/nodes/FieldValuePairQueryNode.java
===================================================================
--- lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/nodes/FieldValuePairQueryNode.java (revision 0)
+++ lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/nodes/FieldValuePairQueryNode.java (revision 0)
@@ -0,0 +1,30 @@
+package org.apache.lucene.queryParser.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 {@link QueryNode} that holds a field
+ * and an arbitrary value.
+ *
+ * @see FieldableNode
+ * @see ValueQueryNode
+ */
+public interface FieldValuePairQueryNode extends
+ FieldableNode, ValueQueryNode {
+
+}
Property changes on: lucene\contrib\queryparser\src\java\org\apache\lucene\queryParser\core\nodes\FieldValuePairQueryNode.java
___________________________________________________________________
Added: svn:keywords
+ Date Author Id Revision HeadURL
Added: svn:eol-style
+ native
Index: lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/nodes/package.html
===================================================================
--- lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/nodes/package.html (revision 1158551)
+++ lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/nodes/package.html (working copy)
@@ -61,6 +61,7 @@
FuzzyQueryNode - fuzzy node
ParametricRangeQueryNode - 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
@@ -68,6 +69,7 @@
Leaf Nodes:
- FieldQueryNode - field/value node
+- NumericQueryNode - used for numeric search
- PathQueryNode - {@link org.apache.lucene.queryParser.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
Index: lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/nodes/ParametricQueryNode.java
===================================================================
--- lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/nodes/ParametricQueryNode.java (revision 1158551)
+++ lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/nodes/ParametricQueryNode.java (working copy)
@@ -22,7 +22,11 @@
/**
* A {@link ParametricQueryNode} represents LE, LT, GE, GT, EQ, NE query.
* Example: date >= "2009-10-10" OR price = 200
+ *
+ * @deprecated this class will be removed in future. {@link FieldQueryNode}
+ * should be used instead.
*/
+@Deprecated
public class ParametricQueryNode extends FieldQueryNode {
private static final long serialVersionUID = -5770038129741218116L;
Index: lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/nodes/ParametricRangeQueryNode.java
===================================================================
--- lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/nodes/ParametricRangeQueryNode.java (revision 1158551)
+++ lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/nodes/ParametricRangeQueryNode.java (working copy)
@@ -27,7 +27,7 @@
* Example: date >= "2009-10-10" OR price = 200
*/
public class ParametricRangeQueryNode extends QueryNodeImpl implements
- FieldableNode {
+ RangeQueryNode {
private static final long serialVersionUID = 7120958816535573935L;
@@ -118,4 +118,12 @@
}
+ public boolean isLowerInclusive() {
+ return getUpperBound().getOperator() == CompareOperator.GE;
+ }
+
+ public boolean isUpperInclusive() {
+ return getLowerBound().getOperator() == CompareOperator.LE;
+ }
+
}
Index: lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/nodes/RangeQueryNode.java
===================================================================
--- lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/nodes/RangeQueryNode.java (revision 0)
+++ lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/nodes/RangeQueryNode.java (revision 0)
@@ -0,0 +1,36 @@
+package org.apache.lucene.queryParser.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();
+
+}
Property changes on: lucene\contrib\queryparser\src\java\org\apache\lucene\queryParser\core\nodes\RangeQueryNode.java
___________________________________________________________________
Added: svn:keywords
+ Date Author Id Revision HeadURL
Added: svn:eol-style
+ native
Index: lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/nodes/ValueQueryNode.java
===================================================================
--- lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/nodes/ValueQueryNode.java (revision 0)
+++ lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/nodes/ValueQueryNode.java (revision 0)
@@ -0,0 +1,30 @@
+package org.apache.lucene.queryParser.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 holds an
+ * arbitrary value.
+ */
+public interface ValueQueryNode extends QueryNode {
+
+ public void setValue(T value);
+
+ public T getValue();
+
+}
Property changes on: lucene\contrib\queryparser\src\java\org\apache\lucene\queryParser\core\nodes\ValueQueryNode.java
___________________________________________________________________
Added: svn:keywords
+ Date Author Id Revision HeadURL
Added: svn:eol-style
+ native
Index: lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/builders/DummyQueryNodeBuilder.java
===================================================================
--- lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/builders/DummyQueryNodeBuilder.java (revision 0)
+++ lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/builders/DummyQueryNodeBuilder.java (revision 0)
@@ -0,0 +1,46 @@
+package org.apache.lucene.queryParser.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.core.QueryNodeException;
+import org.apache.lucene.queryParser.core.nodes.QueryNode;
+import org.apache.lucene.search.TermQuery;
+
+/**
+ * This builder does nothing. Commonly used for {@link QueryNode} objects that
+ * are built by its parent's builder.
+ */
+public class DummyQueryNodeBuilder implements StandardQueryBuilder {
+
+ /**
+ * Constructs a {@link DummyQueryNodeBuilder} object.
+ */
+ public DummyQueryNodeBuilder() {
+ // empty constructor
+ }
+
+ /**
+ * Always return null.
+ *
+ * return null
+ */
+ public TermQuery build(QueryNode queryNode) throws QueryNodeException {
+ return null;
+ }
+
+}
Property changes on: lucene\contrib\queryparser\src\java\org\apache\lucene\queryParser\standard\builders\DummyQueryNodeBuilder.java
___________________________________________________________________
Added: svn:keywords
+ Date Author Id Revision HeadURL
Added: svn:eol-style
+ native
Index: lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/builders/NumericRangeQueryNodeBuilder.java
===================================================================
--- lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/builders/NumericRangeQueryNodeBuilder.java (revision 0)
+++ lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/builders/NumericRangeQueryNodeBuilder.java (revision 0)
@@ -0,0 +1,102 @@
+package org.apache.lucene.queryParser.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.document.NumericField;
+import org.apache.lucene.messages.MessageImpl;
+import org.apache.lucene.queryParser.core.QueryNodeException;
+import org.apache.lucene.queryParser.core.messages.QueryParserMessages;
+import org.apache.lucene.queryParser.core.nodes.QueryNode;
+import org.apache.lucene.queryParser.core.util.StringUtils;
+import org.apache.lucene.queryParser.standard.config.NumericConfig;
+import org.apache.lucene.queryParser.standard.nodes.NumericQueryNode;
+import org.apache.lucene.queryParser.standard.nodes.NumericRangeQueryNode;
+import org.apache.lucene.search.NumericRangeQuery;
+
+/**
+ * Builds {@link NumericRangeQuery}s out of {@link NumericRangeQueryNode}s.
+ *
+ * @see NumericRangeQuery
+ * @see NumericRangeQueryNode
+ */
+public class NumericRangeQueryNodeBuilder implements StandardQueryBuilder {
+
+ /**
+ * Constructs a {@link NumericRangeQueryNodeBuilder} object.
+ */
+ public NumericRangeQueryNodeBuilder() {
+ // empty constructor
+ }
+
+ public NumericRangeQuery extends Number> build(QueryNode queryNode)
+ throws QueryNodeException {
+ NumericRangeQueryNode numericRangeNode = (NumericRangeQueryNode) queryNode;
+
+ NumericQueryNode lowerNumericNode = numericRangeNode.getLowerBound();
+ NumericQueryNode upperNumericNode = numericRangeNode.getUpperBound();
+
+ Number lowerNumber, upperNumber;
+
+ if (lowerNumericNode != null) {
+ lowerNumber = lowerNumericNode.getValue();
+ } else {
+ lowerNumber = null;
+ }
+
+ if (upperNumericNode != null) {
+ upperNumber = upperNumericNode.getValue();
+ } else {
+ upperNumber = null;
+ }
+
+ NumericConfig numericConfig = numericRangeNode.getNumericConfig();
+ NumericField.DataType numberType = numericConfig.getType();
+ String field = StringUtils.toString(numericRangeNode.getField());
+ boolean minInclusive = numericRangeNode.isLowerInclusive();
+ boolean maxInclusive = numericRangeNode.isUpperInclusive();
+ int precisionStep = numericConfig.getPrecisionStep();
+
+ switch (numberType) {
+
+ case LONG:
+ return NumericRangeQuery.newLongRange(field, precisionStep,
+ (Long) lowerNumber, (Long) upperNumber, minInclusive, maxInclusive);
+
+ case INT:
+ return NumericRangeQuery.newIntRange(field, precisionStep,
+ (Integer) lowerNumber, (Integer) upperNumber, minInclusive,
+ maxInclusive);
+
+ case FLOAT:
+ return NumericRangeQuery.newFloatRange(field, precisionStep,
+ (Float) lowerNumber, (Float) upperNumber, minInclusive,
+ maxInclusive);
+
+ case DOUBLE:
+ return NumericRangeQuery.newDoubleRange(field, precisionStep,
+ (Double) lowerNumber, (Double) upperNumber, minInclusive,
+ maxInclusive);
+
+ default :
+ throw new QueryNodeException(new MessageImpl(
+ QueryParserMessages.UNSUPPORTED_NUMERIC_DATA_TYPE, numberType));
+
+ }
+ }
+
+}
Property changes on: lucene\contrib\queryparser\src\java\org\apache\lucene\queryParser\standard\builders\NumericRangeQueryNodeBuilder.java
___________________________________________________________________
Added: svn:keywords
+ Date Author Id Revision HeadURL
Added: svn:eol-style
+ native
Index: lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/builders/RangeQueryNodeBuilder.java
===================================================================
--- lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/builders/RangeQueryNodeBuilder.java (revision 1158551)
+++ lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/builders/RangeQueryNodeBuilder.java (working copy)
@@ -67,5 +67,7 @@
return rangeQuery;
}
+
+
}
Index: lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/builders/StandardQueryTreeBuilder.java
===================================================================
--- lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/builders/StandardQueryTreeBuilder.java (revision 1158551)
+++ lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/builders/StandardQueryTreeBuilder.java (working copy)
@@ -31,9 +31,12 @@
import org.apache.lucene.queryParser.core.nodes.SlopQueryNode;
import org.apache.lucene.queryParser.core.nodes.TokenizedPhraseQueryNode;
import org.apache.lucene.queryParser.standard.nodes.MultiPhraseQueryNode;
+import org.apache.lucene.queryParser.standard.nodes.NumericQueryNode;
+import org.apache.lucene.queryParser.standard.nodes.NumericRangeQueryNode;
import org.apache.lucene.queryParser.standard.nodes.PrefixWildcardQueryNode;
import org.apache.lucene.queryParser.standard.nodes.RangeQueryNode;
import org.apache.lucene.queryParser.standard.nodes.StandardBooleanQueryNode;
+import org.apache.lucene.queryParser.standard.nodes.TermRangeQueryNode;
import org.apache.lucene.queryParser.standard.nodes.WildcardQueryNode;
import org.apache.lucene.queryParser.standard.processors.StandardQueryNodeProcessorPipeline;
import org.apache.lucene.search.Query;
@@ -49,12 +52,14 @@
*/
public class StandardQueryTreeBuilder extends QueryTreeBuilder implements
StandardQueryBuilder {
-
+
public StandardQueryTreeBuilder() {
setBuilder(GroupQueryNode.class, new GroupQueryNodeBuilder());
setBuilder(FieldQueryNode.class, new FieldQueryNodeBuilder());
setBuilder(BooleanQueryNode.class, new BooleanQueryNodeBuilder());
setBuilder(FuzzyQueryNode.class, new FuzzyQueryNodeBuilder());
+ setBuilder(NumericQueryNode.class, new DummyQueryNodeBuilder());
+ setBuilder(NumericRangeQueryNode.class, new NumericRangeQueryNodeBuilder());
setBuilder(BoostQueryNode.class, new BoostQueryNodeBuilder());
setBuilder(ModifierQueryNode.class, new ModifierQueryNodeBuilder());
setBuilder(WildcardQueryNode.class, new WildcardQueryNodeBuilder());
@@ -63,6 +68,7 @@
setBuilder(PrefixWildcardQueryNode.class,
new PrefixWildcardQueryNodeBuilder());
setBuilder(RangeQueryNode.class, new RangeQueryNodeBuilder());
+ setBuilder(TermRangeQueryNode.class, new TermRangeQueryNodeBuilder());
setBuilder(SlopQueryNode.class, new SlopQueryNodeBuilder());
setBuilder(StandardBooleanQueryNode.class,
new StandardBooleanQueryNodeBuilder());
Index: lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/builders/TermRangeQueryNodeBuilder.java
===================================================================
--- lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/builders/TermRangeQueryNodeBuilder.java (revision 0)
+++ lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/builders/TermRangeQueryNodeBuilder.java (revision 0)
@@ -0,0 +1,60 @@
+package org.apache.lucene.queryParser.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.core.QueryNodeException;
+import org.apache.lucene.queryParser.core.nodes.FieldQueryNode;
+import org.apache.lucene.queryParser.core.nodes.QueryNode;
+import org.apache.lucene.queryParser.core.util.StringUtils;
+import org.apache.lucene.queryParser.standard.nodes.TermRangeQueryNode;
+import org.apache.lucene.queryParser.standard.processors.MultiTermRewriteMethodProcessor;
+import org.apache.lucene.search.MultiTermQuery;
+import org.apache.lucene.search.TermRangeQuery;
+
+/**
+ * Builds a {@link TermRangeQuery} object from a {@link TermRangeQueryNode}
+ * object.
+ */
+public class TermRangeQueryNodeBuilder implements StandardQueryBuilder {
+
+ public TermRangeQueryNodeBuilder() {
+ // empty constructor
+ }
+
+ public TermRangeQuery build(QueryNode queryNode) throws QueryNodeException {
+ TermRangeQueryNode rangeNode = (TermRangeQueryNode) queryNode;
+ FieldQueryNode upper = rangeNode.getUpperBound();
+ FieldQueryNode lower = rangeNode.getLowerBound();
+
+ String field = StringUtils.toString(rangeNode.getField());
+
+ TermRangeQuery rangeQuery = new TermRangeQuery(field, lower
+ .getTextAsString(), upper.getTextAsString(), rangeNode
+ .isLowerInclusive(), rangeNode.isUpperInclusive());
+
+ MultiTermQuery.RewriteMethod method = (MultiTermQuery.RewriteMethod) queryNode
+ .getTag(MultiTermRewriteMethodProcessor.TAG_ID);
+ if (method != null) {
+ rangeQuery.setRewriteMethod(method);
+ }
+
+ return rangeQuery;
+
+ }
+
+}
Property changes on: lucene\contrib\queryparser\src\java\org\apache\lucene\queryParser\standard\builders\TermRangeQueryNodeBuilder.java
___________________________________________________________________
Added: svn:keywords
+ Date Author Id Revision HeadURL
Added: svn:eol-style
+ native
Index: lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/NumberDateFormat.java
===================================================================
--- lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/NumberDateFormat.java (revision 0)
+++ lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/NumberDateFormat.java (revision 0)
@@ -0,0 +1,71 @@
+package org.apache.lucene.queryParser.standard.config;
+
+/**
+ * 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.text.FieldPosition;
+import java.text.Format;
+import java.text.NumberFormat;
+import java.text.ParsePosition;
+import java.util.Date;
+
+/**
+ * This {@link Format} parses {@link Long} into date strings and vice-versa. It
+ * uses the given {@link DateFormat} to parse and format dates, but before, it
+ * converts {@link Long} to {@link Date} objects or vice-versa.
+ */
+public class NumberDateFormat extends NumberFormat {
+
+ private static final long serialVersionUID = 964823936071308283L;
+
+ final private DateFormat dateFormat;
+
+ /**
+ * Constructs a {@link NumberDateFormat} object using the given {@link DateFormat}.
+ *
+ * @param dateFormat {@link DateFormat} used to parse and format dates
+ */
+ public NumberDateFormat(DateFormat dateFormat) {
+ this.dateFormat = dateFormat;
+ }
+
+ @Override
+ public StringBuffer format(double number, StringBuffer toAppendTo,
+ FieldPosition pos) {
+ return dateFormat.format(new Date((long) number), toAppendTo, pos);
+ }
+
+ @Override
+ public StringBuffer format(long number, StringBuffer toAppendTo,
+ FieldPosition pos) {
+ return dateFormat.format(new Date(number), toAppendTo, pos);
+ }
+
+ @Override
+ public Number parse(String source, ParsePosition parsePosition) {
+ final Date date = dateFormat.parse(source, parsePosition);
+ return (date == null) ? null : date.getTime();
+ }
+
+ @Override
+ public StringBuffer format(Object number, StringBuffer toAppendTo,
+ FieldPosition pos) {
+ return dateFormat.format(number, toAppendTo, pos);
+ }
+
+}
Property changes on: lucene\contrib\queryparser\src\java\org\apache\lucene\queryParser\standard\config\NumberDateFormat.java
___________________________________________________________________
Added: svn:keywords
+ Date Author Id Revision HeadURL
Added: svn:eol-style
+ native
Index: lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/NumericConfig.java
===================================================================
--- lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/NumericConfig.java (revision 0)
+++ lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/NumericConfig.java (revision 0)
@@ -0,0 +1,159 @@
+package org.apache.lucene.queryParser.standard.config;
+
+/**
+ * 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.NumberFormat;
+
+import org.apache.lucene.document.NumericField;
+import org.apache.lucene.search.NumericRangeQuery;
+
+/**
+ * This class holds the configuration used to parse numeric queries and create
+ * {@link NumericRangeQuery}s.
+ *
+ * @see NumericRangeQuery
+ * @see NumberFormat
+ */
+public class NumericConfig {
+
+ private int precisionStep;
+
+ private NumberFormat format;
+
+ private NumericField.DataType type;
+
+ /**
+ * Constructs a {@link NumericConfig} object.
+ *
+ * @param precisionStep
+ * the precision used to index the numeric values
+ * @param format
+ * the {@link NumberFormat} used to parse a {@link String} to
+ * {@link Number}
+ * @param type
+ * the numeric type used to index the numeric values
+ *
+ * @see NumericConfig#setPrecisionStep(int)
+ * @see NumericConfig#setNumberFormat(NumberFormat)
+ * @see #setType(org.apache.lucene.document.NumericField.DataType)
+ */
+ public NumericConfig(int precisionStep, NumberFormat format,
+ NumericField.DataType type) {
+ setPrecisionStep(precisionStep);
+ setNumberFormat(format);
+ setType(type);
+
+ }
+
+ /**
+ * Returns the precision used to index the numeric values
+ *
+ * @return the precision used to index the numeric values
+ *
+ * @see NumericRangeQuery#getPrecisionStep()
+ */
+ public int getPrecisionStep() {
+ return precisionStep;
+ }
+
+ /**
+ * Sets the precision used to index the numeric values
+ *
+ * @param precisionStep
+ * the precision used to index the numeric values
+ *
+ * @see NumericRangeQuery#getPrecisionStep()
+ */
+ public void setPrecisionStep(int precisionStep) {
+ this.precisionStep = precisionStep;
+ }
+
+ /**
+ * Returns the {@link NumberFormat} used to parse a {@link String} to
+ * {@link Number}
+ *
+ * @return the {@link NumberFormat} used to parse a {@link String} to
+ * {@link Number}
+ */
+ public NumberFormat getNumberFormat() {
+ return format;
+ }
+
+ /**
+ * Returns the numeric type used to index the numeric values
+ *
+ * @return the numeric type used to index the numeric values
+ */
+ public NumericField.DataType getType() {
+ return type;
+ }
+
+ /**
+ * Sets the numeric type used to index the numeric values
+ *
+ * @param type the numeric type used to index the numeric values
+ */
+ public void setType(NumericField.DataType type) {
+
+ if (type == null) {
+ throw new IllegalArgumentException("type cannot be null!");
+ }
+
+ this.type = type;
+
+ }
+
+ /**
+ * Sets the {@link NumberFormat} used to parse a {@link String} to
+ * {@link Number}
+ *
+ * @param format
+ * the {@link NumberFormat} used to parse a {@link String} to
+ * {@link Number}, cannot be null
+ */
+ public void setNumberFormat(NumberFormat format) {
+
+ if (format == null) {
+ throw new IllegalArgumentException("format cannot be null!");
+ }
+
+ this.format = format;
+
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+
+ if (obj == this) return true;
+
+ if (obj instanceof NumericConfig) {
+ NumericConfig other = (NumericConfig) obj;
+
+ if (this.precisionStep == other.precisionStep
+ && this.type == other.type
+ && (this.format == other.format || (this.format.equals(other.format)))) {
+ return true;
+ }
+
+ }
+
+ return false;
+
+ }
+
+}
Property changes on: lucene\contrib\queryparser\src\java\org\apache\lucene\queryParser\standard\config\NumericConfig.java
___________________________________________________________________
Added: svn:keywords
+ Date Author Id Revision HeadURL
Added: svn:eol-style
+ native
Index: lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/NumericFieldConfigListener.java
===================================================================
--- lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/NumericFieldConfigListener.java (revision 0)
+++ lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/NumericFieldConfigListener.java (revision 0)
@@ -0,0 +1,73 @@
+package org.apache.lucene.queryParser.standard.config;
+
+/**
+ * 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.util.Map;
+
+import org.apache.lucene.queryParser.core.config.FieldConfig;
+import org.apache.lucene.queryParser.core.config.FieldConfigListener;
+import org.apache.lucene.queryParser.core.config.QueryConfigHandler;
+import org.apache.lucene.queryParser.standard.config.StandardQueryConfigHandler.ConfigurationKeys;
+
+/**
+ * This listener is used to listen to {@link FieldConfig} requests in
+ * {@link QueryConfigHandler} and add {@link ConfigurationKeys#NUMERIC_CONFIG}
+ * based on the {@link ConfigurationKeys#NUMERIC_CONFIG_MAP} set in the
+ * {@link QueryConfigHandler}.
+ *
+ * @see NumericConfig
+ * @see QueryConfigHandler
+ * @see ConfigurationKeys#NUMERIC_CONFIG
+ * @see ConfigurationKeys#NUMERIC_CONFIG_MAP
+ */
+public class NumericFieldConfigListener implements FieldConfigListener {
+
+ final private QueryConfigHandler config;
+
+ /**
+ * Construcs a {@link NumericFieldConfigListener} object using the given {@link QueryConfigHandler}.
+ *
+ * @param config the {@link QueryConfigHandler} it will listen too
+ */
+ public NumericFieldConfigListener(QueryConfigHandler config) {
+
+ if (config == null) {
+ throw new IllegalArgumentException("config cannot be null!");
+ }
+
+ this.config = config;
+
+ }
+
+ public void buildFieldConfig(FieldConfig fieldConfig) {
+ Map numericConfigMap = config
+ .get(ConfigurationKeys.NUMERIC_CONFIG_MAP);
+
+ if (numericConfigMap != null) {
+ NumericConfig numericConfig = numericConfigMap
+ .get(fieldConfig.getField());
+
+ if (numericConfig != null) {
+ fieldConfig.set(ConfigurationKeys.NUMERIC_CONFIG, numericConfig);
+ }
+
+ }
+
+ }
+
+}
Property changes on: lucene\contrib\queryparser\src\java\org\apache\lucene\queryParser\standard\config\NumericFieldConfigListener.java
___________________________________________________________________
Added: svn:keywords
+ Date Author Id Revision HeadURL
Added: svn:eol-style
+ native
Index: lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/StandardQueryConfigHandler.java
===================================================================
--- lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/StandardQueryConfigHandler.java (revision 1158551)
+++ lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/StandardQueryConfigHandler.java (working copy)
@@ -177,6 +177,26 @@
*/
final public static ConfigurationKey BOOST = ConfigurationKey
.newInstance();
+
+ /**
+ * Key used to set a field to its {@link NumericConfig}.
+ *
+ * @see StandardQueryParser#setNumericConfigMap(Map)
+ * @see StandardQueryParser#getNumericConfigMap()
+ */
+ final public static ConfigurationKey NUMERIC_CONFIG = ConfigurationKey
+ .newInstance();
+
+ /**
+ * Key used to set the {@link NumericConfig} in {@link FieldConfig} for
+ * numeric fields.
+ *
+ * @see StandardQueryParser#setNumericConfigMap(Map)
+ * @see StandardQueryParser#getNumericConfigMap()
+ */
+ final public static ConfigurationKey