mirror of https://github.com/apache/lucene.git
LUCENE-1768: Cleanup in trunk (removal of deprecated stuff, unused subclasses in between)
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1166789 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0279c192a9
commit
31495a1d2c
|
@ -7,19 +7,19 @@ http://s.apache.org/luceneversions
|
||||||
|
|
||||||
Changes in runtime behavior
|
Changes in runtime behavior
|
||||||
|
|
||||||
* LUCENE-1768: StandardQueryTreeBuilder uses RangeQueryNodeBuilder for
|
* LUCENE-1768: StandardQueryTreeBuilder no longer uses RangeQueryNodeBuilder
|
||||||
RangeQueryNodes, since theses two classes were removed;
|
for RangeQueryNodes, since theses two classes were removed;
|
||||||
ParametricRangeQueryNodeProcessor now creates TermRangeQueryNode,
|
TermRangeQueryNodeProcessor now creates TermRangeQueryNode,
|
||||||
instead of RangeQueryNode, from ParametricRangeQueryNode
|
instead of RangeQueryNode; the same applies for numeric nodes;
|
||||||
(Vinicius Barros via Uwe Schindler)
|
(Vinicius Barros via Uwe Schindler)
|
||||||
|
|
||||||
API Changes
|
API Changes
|
||||||
|
|
||||||
* LUCENE-1768: ParametricRangeQueryNode now implements
|
* LUCENE-1768: Deprecated Parametric(Range)QueryNode, RangeQueryNode(Builder),
|
||||||
RangeQueryNode<FieldQueryNode> instead of
|
ParametricRangeQueryNodeProcessor were removed. (Vinicius Barros via Uwe Schindler)
|
||||||
RangeQueryNode<ParametricQueryNode> (Vinicius Barros via Uwe Schindler)
|
|
||||||
|
|
||||||
Bug fixes
|
Bug fixes
|
||||||
|
|
||||||
* LUCENE-2945: Fix hashCode/equals for surround query parser generated queries.
|
* LUCENE-2945: Fix hashCode/equals for surround query parser generated queries.
|
||||||
(Paul Elschot, Simon Rosenthal, gsingers via ehatcher)
|
(Paul Elschot, Simon Rosenthal, gsingers via ehatcher)
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ implementation.
|
||||||
<p>
|
<p>
|
||||||
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
|
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.
|
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.
|
reference implementation.
|
||||||
</p>
|
</p>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -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 "<parametric field='" + this.field + "' operator='"
|
|
||||||
+ this.operator.toString() + "' text='" + this.text + "'/>";
|
|
||||||
}
|
|
||||||
|
|
||||||
@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;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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("<parametricRange>\n\t");
|
|
||||||
sb.append(getUpperBound()).append("\n\t");
|
|
||||||
sb.append(getLowerBound()).append("\n");
|
|
||||||
sb.append("</parametricRange>\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<QueryNode> children = getChildren();
|
|
||||||
|
|
||||||
if (children != null) {
|
|
||||||
|
|
||||||
for (QueryNode child : getChildren()) {
|
|
||||||
|
|
||||||
if (child instanceof FieldableNode) {
|
|
||||||
((FieldableNode) child).setField(fieldName);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -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<T extends FieldValuePairQueryNode<?>> extends
|
||||||
|
FieldableNode {
|
||||||
|
|
||||||
|
T getLowerBound();
|
||||||
|
|
||||||
|
T getUpperBound();
|
||||||
|
|
||||||
|
boolean isLowerInclusive();
|
||||||
|
|
||||||
|
boolean isUpperInclusive();
|
||||||
|
|
||||||
|
}
|
|
@ -59,7 +59,7 @@ Grouping nodes:
|
||||||
<li>BoostQueryNode - used for boost operator</li>
|
<li>BoostQueryNode - used for boost operator</li>
|
||||||
<li>SlopQueryNode - phrase slop</li>
|
<li>SlopQueryNode - phrase slop</li>
|
||||||
<li>FuzzyQueryNode - fuzzy node</li>
|
<li>FuzzyQueryNode - fuzzy node</li>
|
||||||
<li>ParametricRangeQueryNode - used for parametric field:[low_value TO high_value]</li>
|
<li>TermRangeQueryNode - used for parametric field:[low_value TO high_value]</li>
|
||||||
<li>ProximityQueryNode - used for proximity search</li>
|
<li>ProximityQueryNode - used for proximity search</li>
|
||||||
<li>NumericRangeQueryNode - used for numeric range search</li>
|
<li>NumericRangeQueryNode - used for numeric range search</li>
|
||||||
<li>TokenizedPhraseQueryNode - used by tokenizers/lemmatizers/analyzers for phrases/autophrases</li>
|
<li>TokenizedPhraseQueryNode - used by tokenizers/lemmatizers/analyzers for phrases/autophrases</li>
|
||||||
|
@ -72,7 +72,6 @@ Leaf Nodes:
|
||||||
<li>NumericQueryNode - used for numeric search</li>
|
<li>NumericQueryNode - used for numeric search</li>
|
||||||
<li>PathQueryNode - {@link org.apache.lucene.queryparser.flexible.core.nodes.QueryNode} object used with path-like queries</li>
|
<li>PathQueryNode - {@link org.apache.lucene.queryparser.flexible.core.nodes.QueryNode} object used with path-like queries</li>
|
||||||
<li>OpaqueQueryNode - Used as for part of the query that can be parsed by other parsers. schema/value</li>
|
<li>OpaqueQueryNode - Used as for part of the query that can be parsed by other parsers. schema/value</li>
|
||||||
<li>ParametricQueryNode - used for parametric field [>=|<=|=|<|>] value</li>
|
|
||||||
<li>PrefixWildcardQueryNode - non-phrase wildcard query</li>
|
<li>PrefixWildcardQueryNode - non-phrase wildcard query</li>
|
||||||
<li>QuotedFieldQUeryNode - regular phrase node</li>
|
<li>QuotedFieldQUeryNode - regular phrase node</li>
|
||||||
<li>WildcardQueryNode - non-phrase wildcard query</li>
|
<li>WildcardQueryNode - non-phrase wildcard query</li>
|
||||||
|
|
|
@ -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;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -23,16 +23,18 @@ import org.apache.lucene.queryparser.flexible.core.nodes.FieldValuePairQueryNode
|
||||||
import org.apache.lucene.queryparser.flexible.core.nodes.FieldableNode;
|
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.QueryNode;
|
||||||
import org.apache.lucene.queryparser.flexible.core.nodes.QueryNodeImpl;
|
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.parser.EscapeQuerySyntax;
|
||||||
import org.apache.lucene.queryparser.flexible.core.util.StringUtils;
|
import org.apache.lucene.queryparser.flexible.core.util.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class should be extended by nodes intending to represent range queries.
|
* This class should be extended by nodes intending to represent range queries.
|
||||||
*
|
*
|
||||||
* @param <T> the type of the range query bounds (lower and upper)
|
* @param <T>
|
||||||
|
* the type of the range query bounds (lower and upper)
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractRangeQueryNode<T extends FieldValuePairQueryNode<?>>
|
public class AbstractRangeQueryNode<T extends FieldValuePairQueryNode<?>>
|
||||||
extends QueryNodeImpl implements FieldableNode {
|
extends QueryNodeImpl implements RangeQueryNode<FieldValuePairQueryNode<?>> {
|
||||||
|
|
||||||
private boolean lowerInclusive, upperInclusive;
|
private boolean lowerInclusive, upperInclusive;
|
||||||
|
|
||||||
|
@ -145,8 +147,9 @@ public abstract class AbstractRangeQueryNode<T extends FieldValuePairQueryNode<?
|
||||||
String lowerField = StringUtils.toString(lower.getField());
|
String lowerField = StringUtils.toString(lower.getField());
|
||||||
String upperField = StringUtils.toString(upper.getField());
|
String upperField = StringUtils.toString(upper.getField());
|
||||||
|
|
||||||
if ((upperField == null && lowerField == null)
|
if ((upperField != null || lowerField != null)
|
||||||
|| (upperField != null && !upperField.equals(lowerField))) {
|
&& ((upperField != null && !upperField.equals(lowerField)) || !lowerField
|
||||||
|
.equals(upperField))) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"lower and upper bounds should have the same field name!");
|
"lower and upper bounds should have the same field name!");
|
||||||
}
|
}
|
||||||
|
|
|
@ -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("<range>\n\t");
|
|
||||||
sb.append(this.getUpperBound()).append("\n\t");
|
|
||||||
sb.append(this.getLowerBound()).append("\n");
|
|
||||||
sb.append("</range>\n");
|
|
||||||
|
|
||||||
return sb.toString();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -33,13 +33,12 @@ import org.apache.lucene.queryparser.flexible.core.nodes.FuzzyQueryNode;
|
||||||
import org.apache.lucene.queryparser.flexible.core.nodes.ModifierQueryNode;
|
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.GroupQueryNode;
|
||||||
import org.apache.lucene.queryparser.flexible.core.nodes.OrQueryNode;
|
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.standard.nodes.RegexpQueryNode;
|
||||||
import org.apache.lucene.queryparser.flexible.core.nodes.SlopQueryNode;
|
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.QueryNode;
|
||||||
import org.apache.lucene.queryparser.flexible.core.nodes.QuotedFieldQueryNode;
|
import org.apache.lucene.queryparser.flexible.core.nodes.QuotedFieldQueryNode;
|
||||||
import org.apache.lucene.queryparser.flexible.core.parser.SyntaxParser;
|
import org.apache.lucene.queryparser.flexible.core.parser.SyntaxParser;
|
||||||
|
import org.apache.lucene.queryparser.flexible.standard.nodes.TermRangeQueryNode;
|
||||||
|
|
||||||
public class StandardSyntaxParser implements SyntaxParser, StandardSyntaxParserConstants {
|
public class StandardSyntaxParser implements SyntaxParser, StandardSyntaxParserConstants {
|
||||||
|
|
||||||
|
@ -309,7 +308,8 @@ public class StandardSyntaxParser implements SyntaxParser, StandardSyntaxParserC
|
||||||
final public QueryNode Clause(CharSequence field) throws ParseException {
|
final public QueryNode Clause(CharSequence field) throws ParseException {
|
||||||
QueryNode q;
|
QueryNode q;
|
||||||
Token fieldToken=null, boost=null, operator=null, term=null;
|
Token fieldToken=null, boost=null, operator=null, term=null;
|
||||||
ParametricQueryNode qLower, qUpper;
|
FieldQueryNode qLower, qUpper;
|
||||||
|
boolean lowerInclusive, upperInclusive;
|
||||||
|
|
||||||
boolean group = false;
|
boolean group = false;
|
||||||
if (jj_2_2(3)) {
|
if (jj_2_2(3)) {
|
||||||
|
@ -375,33 +375,46 @@ public class StandardSyntaxParser implements SyntaxParser, StandardSyntaxParserC
|
||||||
}
|
}
|
||||||
switch (operator.kind) {
|
switch (operator.kind) {
|
||||||
case OP_LESSTHAN:
|
case OP_LESSTHAN:
|
||||||
qLower = new ParametricQueryNode(field, ParametricQueryNode.CompareOperator.GE,
|
lowerInclusive = true;
|
||||||
|
upperInclusive = false;
|
||||||
|
|
||||||
|
qLower = new FieldQueryNode(field,
|
||||||
"*", term.beginColumn, term.endColumn);
|
"*", term.beginColumn, term.endColumn);
|
||||||
qUpper = new ParametricQueryNode(field, ParametricQueryNode.CompareOperator.LT,
|
qUpper = new FieldQueryNode(field,
|
||||||
EscapeQuerySyntaxImpl.discardEscapeChar(term.image), term.beginColumn, term.endColumn);
|
EscapeQuerySyntaxImpl.discardEscapeChar(term.image), term.beginColumn, term.endColumn);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case OP_LESSTHANEQ:
|
case OP_LESSTHANEQ:
|
||||||
qLower = new ParametricQueryNode(field, ParametricQueryNode.CompareOperator.GE,
|
lowerInclusive = true;
|
||||||
|
upperInclusive = true;
|
||||||
|
|
||||||
|
qLower = new FieldQueryNode(field,
|
||||||
"*", term.beginColumn, term.endColumn);
|
"*", term.beginColumn, term.endColumn);
|
||||||
qUpper = new ParametricQueryNode(field, ParametricQueryNode.CompareOperator.LE,
|
qUpper = new FieldQueryNode(field,
|
||||||
EscapeQuerySyntaxImpl.discardEscapeChar(term.image), term.beginColumn, term.endColumn);
|
EscapeQuerySyntaxImpl.discardEscapeChar(term.image), term.beginColumn, term.endColumn);
|
||||||
break;
|
break;
|
||||||
case OP_MORETHAN:
|
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);
|
EscapeQuerySyntaxImpl.discardEscapeChar(term.image), term.beginColumn, term.endColumn);
|
||||||
qUpper = new ParametricQueryNode(field, ParametricQueryNode.CompareOperator.LE,
|
qUpper = new FieldQueryNode(field,
|
||||||
"*", term.beginColumn, term.endColumn);
|
"*", term.beginColumn, term.endColumn);
|
||||||
break;
|
break;
|
||||||
case OP_MORETHANEQ:
|
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);
|
EscapeQuerySyntaxImpl.discardEscapeChar(term.image), term.beginColumn, term.endColumn);
|
||||||
qUpper = new ParametricQueryNode(field, ParametricQueryNode.CompareOperator.LE,
|
qUpper = new FieldQueryNode(field,
|
||||||
"*", term.beginColumn, term.endColumn);
|
"*", term.beginColumn, term.endColumn);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
{if (true) throw new Error("Unhandled case: operator="+operator.toString());}
|
{if (true) throw new Error("Unhandled case: operator="+operator.toString());}
|
||||||
}
|
}
|
||||||
q = new ParametricRangeQueryNode(qLower, qUpper);
|
q = new TermRangeQueryNode(qLower, qUpper, lowerInclusive, upperInclusive);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
jj_la1[10] = jj_gen;
|
jj_la1[10] = jj_gen;
|
||||||
|
@ -497,7 +510,7 @@ public class StandardSyntaxParser implements SyntaxParser, StandardSyntaxParserC
|
||||||
boolean startInc=false;
|
boolean startInc=false;
|
||||||
boolean endInc=false;
|
boolean endInc=false;
|
||||||
QueryNode q =null;
|
QueryNode q =null;
|
||||||
ParametricQueryNode qLower, qUpper;
|
FieldQueryNode qLower, qUpper;
|
||||||
float defaultMinSimilarity = org.apache.lucene.search.FuzzyQuery.defaultMinSimilarity;
|
float defaultMinSimilarity = org.apache.lucene.search.FuzzyQuery.defaultMinSimilarity;
|
||||||
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
|
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
|
||||||
case TERM:
|
case TERM:
|
||||||
|
@ -638,11 +651,11 @@ public class StandardSyntaxParser implements SyntaxParser, StandardSyntaxParserC
|
||||||
goop2.image = goop2.image.substring(1, goop2.image.length()-1);
|
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);
|
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);
|
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;
|
break;
|
||||||
case QUOTED:
|
case QUOTED:
|
||||||
term = jj_consume_token(QUOTED);
|
term = jj_consume_token(QUOTED);
|
||||||
|
@ -726,8 +739,16 @@ public class StandardSyntaxParser implements SyntaxParser, StandardSyntaxParserC
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean jj_3R_10() {
|
private boolean jj_3R_6() {
|
||||||
if (jj_scan_token(TERM)) return true;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -742,6 +763,11 @@ public class StandardSyntaxParser implements SyntaxParser, StandardSyntaxParserC
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean jj_3R_10() {
|
||||||
|
if (jj_scan_token(TERM)) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private boolean jj_3R_12() {
|
private boolean jj_3R_12() {
|
||||||
if (jj_scan_token(RANGEIN_START)) return true;
|
if (jj_scan_token(RANGEIN_START)) return true;
|
||||||
return false;
|
return false;
|
||||||
|
@ -786,24 +812,6 @@ public class StandardSyntaxParser implements SyntaxParser, StandardSyntaxParserC
|
||||||
return false;
|
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() {
|
private boolean jj_3R_5() {
|
||||||
Token xsp;
|
Token xsp;
|
||||||
xsp = jj_scanpos;
|
xsp = jj_scanpos;
|
||||||
|
@ -828,6 +836,11 @@ public class StandardSyntaxParser implements SyntaxParser, StandardSyntaxParserC
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean jj_3R_9() {
|
||||||
|
if (jj_scan_token(QUOTED)) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/** Generated Token Manager. */
|
/** Generated Token Manager. */
|
||||||
public StandardSyntaxParserTokenManager token_source;
|
public StandardSyntaxParserTokenManager token_source;
|
||||||
JavaCharStream jj_input_stream;
|
JavaCharStream jj_input_stream;
|
||||||
|
|
|
@ -45,13 +45,12 @@ import org.apache.lucene.queryparser.flexible.core.nodes.FuzzyQueryNode;
|
||||||
import org.apache.lucene.queryparser.flexible.core.nodes.ModifierQueryNode;
|
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.GroupQueryNode;
|
||||||
import org.apache.lucene.queryparser.flexible.core.nodes.OrQueryNode;
|
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.standard.nodes.RegexpQueryNode;
|
||||||
import org.apache.lucene.queryparser.flexible.core.nodes.SlopQueryNode;
|
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.QueryNode;
|
||||||
import org.apache.lucene.queryparser.flexible.core.nodes.QuotedFieldQueryNode;
|
import org.apache.lucene.queryparser.flexible.core.nodes.QuotedFieldQueryNode;
|
||||||
import org.apache.lucene.queryparser.flexible.core.parser.SyntaxParser;
|
import org.apache.lucene.queryparser.flexible.core.parser.SyntaxParser;
|
||||||
|
import org.apache.lucene.queryparser.flexible.standard.nodes.TermRangeQueryNode;
|
||||||
|
|
||||||
public class StandardSyntaxParser implements SyntaxParser {
|
public class StandardSyntaxParser implements SyntaxParser {
|
||||||
|
|
||||||
|
@ -328,7 +327,8 @@ QueryNode ModClause(CharSequence field) : {
|
||||||
QueryNode Clause(CharSequence field) : {
|
QueryNode Clause(CharSequence field) : {
|
||||||
QueryNode q;
|
QueryNode q;
|
||||||
Token fieldToken=null, boost=null, operator=null, term=null;
|
Token fieldToken=null, boost=null, operator=null, term=null;
|
||||||
ParametricQueryNode qLower, qUpper;
|
FieldQueryNode qLower, qUpper;
|
||||||
|
boolean lowerInclusive, upperInclusive;
|
||||||
|
|
||||||
boolean group = false;
|
boolean group = false;
|
||||||
}
|
}
|
||||||
|
@ -344,33 +344,46 @@ QueryNode Clause(CharSequence field) : {
|
||||||
}
|
}
|
||||||
switch (operator.kind) {
|
switch (operator.kind) {
|
||||||
case OP_LESSTHAN:
|
case OP_LESSTHAN:
|
||||||
qLower = new ParametricQueryNode(field, ParametricQueryNode.CompareOperator.GE,
|
lowerInclusive = true;
|
||||||
|
upperInclusive = false;
|
||||||
|
|
||||||
|
qLower = new FieldQueryNode(field,
|
||||||
"*", term.beginColumn, term.endColumn);
|
"*", term.beginColumn, term.endColumn);
|
||||||
qUpper = new ParametricQueryNode(field, ParametricQueryNode.CompareOperator.LT,
|
qUpper = new FieldQueryNode(field,
|
||||||
EscapeQuerySyntaxImpl.discardEscapeChar(term.image), term.beginColumn, term.endColumn);
|
EscapeQuerySyntaxImpl.discardEscapeChar(term.image), term.beginColumn, term.endColumn);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case OP_LESSTHANEQ:
|
case OP_LESSTHANEQ:
|
||||||
qLower = new ParametricQueryNode(field, ParametricQueryNode.CompareOperator.GE,
|
lowerInclusive = true;
|
||||||
|
upperInclusive = true;
|
||||||
|
|
||||||
|
qLower = new FieldQueryNode(field,
|
||||||
"*", term.beginColumn, term.endColumn);
|
"*", term.beginColumn, term.endColumn);
|
||||||
qUpper = new ParametricQueryNode(field, ParametricQueryNode.CompareOperator.LE,
|
qUpper = new FieldQueryNode(field,
|
||||||
EscapeQuerySyntaxImpl.discardEscapeChar(term.image), term.beginColumn, term.endColumn);
|
EscapeQuerySyntaxImpl.discardEscapeChar(term.image), term.beginColumn, term.endColumn);
|
||||||
break;
|
break;
|
||||||
case OP_MORETHAN:
|
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);
|
EscapeQuerySyntaxImpl.discardEscapeChar(term.image), term.beginColumn, term.endColumn);
|
||||||
qUpper = new ParametricQueryNode(field, ParametricQueryNode.CompareOperator.LE,
|
qUpper = new FieldQueryNode(field,
|
||||||
"*", term.beginColumn, term.endColumn);
|
"*", term.beginColumn, term.endColumn);
|
||||||
break;
|
break;
|
||||||
case OP_MORETHANEQ:
|
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);
|
EscapeQuerySyntaxImpl.discardEscapeChar(term.image), term.beginColumn, term.endColumn);
|
||||||
qUpper = new ParametricQueryNode(field, ParametricQueryNode.CompareOperator.LE,
|
qUpper = new FieldQueryNode(field,
|
||||||
"*", term.beginColumn, term.endColumn);
|
"*", term.beginColumn, term.endColumn);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Error("Unhandled case: operator="+operator.toString());
|
throw new Error("Unhandled case: operator="+operator.toString());
|
||||||
}
|
}
|
||||||
q = new ParametricRangeQueryNode(qLower, qUpper);
|
q = new TermRangeQueryNode(qLower, qUpper, lowerInclusive, upperInclusive);
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
| [
|
| [
|
||||||
|
@ -411,7 +424,7 @@ QueryNode Term(CharSequence field) : {
|
||||||
boolean startInc=false;
|
boolean startInc=false;
|
||||||
boolean endInc=false;
|
boolean endInc=false;
|
||||||
QueryNode q =null;
|
QueryNode q =null;
|
||||||
ParametricQueryNode qLower, qUpper;
|
FieldQueryNode qLower, qUpper;
|
||||||
float defaultMinSimilarity = org.apache.lucene.search.FuzzyQuery.defaultMinSimilarity;
|
float defaultMinSimilarity = org.apache.lucene.search.FuzzyQuery.defaultMinSimilarity;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
@ -453,11 +466,11 @@ QueryNode Term(CharSequence field) : {
|
||||||
goop2.image = goop2.image.substring(1, goop2.image.length()-1);
|
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);
|
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);
|
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=<QUOTED> {q = new QuotedFieldQueryNode(field, EscapeQuerySyntaxImpl.discardEscapeChar(term.image.substring(1, term.image.length()-1)), term.beginColumn + 1, term.endColumn - 1);}
|
| term=<QUOTED> {q = new QuotedFieldQueryNode(field, EscapeQuerySyntaxImpl.discardEscapeChar(term.image.substring(1, term.image.length()-1)), term.beginColumn + 1, term.endColumn - 1);}
|
||||||
[ fuzzySlop=<FUZZY_SLOP> ]
|
[ fuzzySlop=<FUZZY_SLOP> ]
|
||||||
|
|
|
@ -31,13 +31,12 @@ import org.apache.lucene.queryparser.flexible.core.nodes.FuzzyQueryNode;
|
||||||
import org.apache.lucene.queryparser.flexible.core.nodes.ModifierQueryNode;
|
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.GroupQueryNode;
|
||||||
import org.apache.lucene.queryparser.flexible.core.nodes.OrQueryNode;
|
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.standard.nodes.RegexpQueryNode;
|
||||||
import org.apache.lucene.queryparser.flexible.core.nodes.SlopQueryNode;
|
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.QueryNode;
|
||||||
import org.apache.lucene.queryparser.flexible.core.nodes.QuotedFieldQueryNode;
|
import org.apache.lucene.queryparser.flexible.core.nodes.QuotedFieldQueryNode;
|
||||||
import org.apache.lucene.queryparser.flexible.core.parser.SyntaxParser;
|
import org.apache.lucene.queryparser.flexible.core.parser.SyntaxParser;
|
||||||
|
import org.apache.lucene.queryparser.flexible.standard.nodes.TermRangeQueryNode;
|
||||||
|
|
||||||
/** Token Manager. */
|
/** Token Manager. */
|
||||||
public class StandardSyntaxParserTokenManager implements StandardSyntaxParserConstants
|
public class StandardSyntaxParserTokenManager implements StandardSyntaxParserConstants
|
||||||
|
|
|
@ -34,9 +34,9 @@ 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.FuzzyQueryNode;
|
||||||
import org.apache.lucene.queryparser.flexible.core.nodes.GroupQueryNode;
|
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.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.QueryNode;
|
||||||
import org.apache.lucene.queryparser.flexible.core.nodes.QuotedFieldQueryNode;
|
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.TextableQueryNode;
|
||||||
import org.apache.lucene.queryparser.flexible.core.nodes.TokenizedPhraseQueryNode;
|
import org.apache.lucene.queryparser.flexible.core.nodes.TokenizedPhraseQueryNode;
|
||||||
import org.apache.lucene.queryparser.flexible.core.processors.QueryNodeProcessorImpl;
|
import org.apache.lucene.queryparser.flexible.core.processors.QueryNodeProcessorImpl;
|
||||||
|
@ -50,7 +50,7 @@ import org.apache.lucene.queryparser.flexible.standard.nodes.WildcardQueryNode;
|
||||||
* is defined in the {@link QueryConfigHandler}. If it is and the analyzer is
|
* is defined in the {@link QueryConfigHandler}. If it is and the analyzer is
|
||||||
* not <code>null</code>, it looks for every {@link FieldQueryNode} that is not
|
* not <code>null</code>, it looks for every {@link FieldQueryNode} that is not
|
||||||
* {@link WildcardQueryNode}, {@link FuzzyQueryNode} or
|
* {@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. <br/>
|
* the analyzer to that {@link FieldQueryNode} object. <br/>
|
||||||
* <br/>
|
* <br/>
|
||||||
* If the analyzer return only one term, the returned term is set to the
|
* If the analyzer return only one term, the returned term is set to the
|
||||||
|
@ -106,7 +106,7 @@ public class AnalyzerQueryNodeProcessor extends QueryNodeProcessorImpl {
|
||||||
if (node instanceof TextableQueryNode
|
if (node instanceof TextableQueryNode
|
||||||
&& !(node instanceof WildcardQueryNode)
|
&& !(node instanceof WildcardQueryNode)
|
||||||
&& !(node instanceof FuzzyQueryNode)
|
&& !(node instanceof FuzzyQueryNode)
|
||||||
&& !(node instanceof ParametricQueryNode)) {
|
&& !(node.getParent() instanceof RangeQueryNode)) {
|
||||||
|
|
||||||
FieldQueryNode fieldNode = ((FieldQueryNode) node);
|
FieldQueryNode fieldNode = ((FieldQueryNode) node);
|
||||||
String text = fieldNode.getTextAsString();
|
String text = fieldNode.getTextAsString();
|
||||||
|
|
|
@ -21,9 +21,10 @@ import java.util.List;
|
||||||
|
|
||||||
import org.apache.lucene.queryparser.flexible.core.QueryNodeException;
|
import org.apache.lucene.queryparser.flexible.core.QueryNodeException;
|
||||||
import org.apache.lucene.queryparser.flexible.core.config.QueryConfigHandler;
|
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.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.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.nodes.TextableQueryNode;
|
||||||
import org.apache.lucene.queryparser.flexible.core.processors.QueryNodeProcessorImpl;
|
import org.apache.lucene.queryparser.flexible.core.processors.QueryNodeProcessorImpl;
|
||||||
import org.apache.lucene.queryparser.flexible.core.util.UnescapedCharSequence;
|
import org.apache.lucene.queryparser.flexible.core.util.UnescapedCharSequence;
|
||||||
|
@ -36,7 +37,7 @@ import org.apache.lucene.queryparser.flexible.standard.nodes.WildcardQueryNode;
|
||||||
* {@link ConfigurationKeys#LOWERCASE_EXPANDED_TERMS} is defined in the
|
* {@link ConfigurationKeys#LOWERCASE_EXPANDED_TERMS} is defined in the
|
||||||
* {@link QueryConfigHandler}. If it is and the expanded terms should be
|
* {@link QueryConfigHandler}. If it is and the expanded terms should be
|
||||||
* lower-cased, it looks for every {@link WildcardQueryNode},
|
* 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. <br/>
|
* term. <br/>
|
||||||
*
|
*
|
||||||
* @see ConfigurationKeys#LOWERCASE_EXPANDED_TERMS
|
* @see ConfigurationKeys#LOWERCASE_EXPANDED_TERMS
|
||||||
|
@ -63,8 +64,10 @@ public class LowercaseExpandedTermsQueryNodeProcessor extends
|
||||||
@Override
|
@Override
|
||||||
protected QueryNode postProcessNode(QueryNode node) throws QueryNodeException {
|
protected QueryNode postProcessNode(QueryNode node) throws QueryNodeException {
|
||||||
|
|
||||||
if (node instanceof WildcardQueryNode || node instanceof FuzzyQueryNode
|
if (node instanceof WildcardQueryNode
|
||||||
|| node instanceof ParametricQueryNode || node instanceof RegexpQueryNode) {
|
|| node instanceof FuzzyQueryNode
|
||||||
|
|| (node instanceof FieldQueryNode && node.getParent() instanceof RangeQueryNode)
|
||||||
|
|| node instanceof RegexpQueryNode) {
|
||||||
|
|
||||||
TextableQueryNode txtNode = (TextableQueryNode) node;
|
TextableQueryNode txtNode = (TextableQueryNode) node;
|
||||||
CharSequence text = txtNode.getText();
|
CharSequence text = txtNode.getText();
|
||||||
|
|
|
@ -28,9 +28,8 @@ 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.config.QueryConfigHandler;
|
||||||
import org.apache.lucene.queryparser.flexible.core.messages.QueryParserMessages;
|
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.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.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.core.processors.QueryNodeProcessorImpl;
|
||||||
import org.apache.lucene.queryparser.flexible.standard.config.NumericConfig;
|
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.config.StandardQueryConfigHandler.ConfigurationKeys;
|
||||||
|
@ -46,11 +45,11 @@ import org.apache.lucene.queryparser.flexible.standard.nodes.NumericRangeQueryNo
|
||||||
* {@link FieldQueryNode} to be a numeric query and convert it to
|
* {@link FieldQueryNode} to be a numeric query and convert it to
|
||||||
* {@link NumericRangeQueryNode} with upper and lower inclusive and lower and
|
* {@link NumericRangeQueryNode} with upper and lower inclusive and lower and
|
||||||
* upper equals to the value represented by the {@link FieldQueryNode} converted
|
* upper equals to the value represented by the {@link FieldQueryNode} converted
|
||||||
* to {@link Number}. It means that <b>field:1</b> is converted to <b>field:[1 TO
|
* to {@link Number}. It means that <b>field:1</b> is converted to <b>field:[1
|
||||||
* 1]</b>. <br/>
|
* TO 1]</b>. <br/>
|
||||||
* <br/>
|
* <br/>
|
||||||
* Note that {@link ParametricQueryNode}s are ignored, even being a
|
* Note that {@link FieldQueryNode}s children of a
|
||||||
* {@link FieldQueryNode}.
|
* {@link RangeQueryNode} are ignored.
|
||||||
*
|
*
|
||||||
* @see ConfigurationKeys#NUMERIC_CONFIG
|
* @see ConfigurationKeys#NUMERIC_CONFIG
|
||||||
* @see FieldQueryNode
|
* @see FieldQueryNode
|
||||||
|
@ -70,7 +69,7 @@ public class NumericQueryNodeProcessor extends QueryNodeProcessorImpl {
|
||||||
protected QueryNode postProcessNode(QueryNode node) throws QueryNodeException {
|
protected QueryNode postProcessNode(QueryNode node) throws QueryNodeException {
|
||||||
|
|
||||||
if (node instanceof FieldQueryNode
|
if (node instanceof FieldQueryNode
|
||||||
&& !(node.getParent() instanceof ParametricRangeQueryNode)) {
|
&& !(node.getParent() instanceof RangeQueryNode)) {
|
||||||
|
|
||||||
QueryConfigHandler config = getQueryConfigHandler();
|
QueryConfigHandler config = getQueryConfigHandler();
|
||||||
|
|
||||||
|
|
|
@ -27,28 +27,27 @@ import org.apache.lucene.queryparser.flexible.core.QueryNodeParseException;
|
||||||
import org.apache.lucene.queryparser.flexible.core.config.FieldConfig;
|
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.config.QueryConfigHandler;
|
||||||
import org.apache.lucene.queryparser.flexible.core.messages.QueryParserMessages;
|
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.FieldQueryNode;
|
||||||
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.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.processors.QueryNodeProcessorImpl;
|
||||||
import org.apache.lucene.queryparser.flexible.core.util.StringUtils;
|
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.NumericConfig;
|
||||||
import org.apache.lucene.queryparser.flexible.standard.config.StandardQueryConfigHandler.ConfigurationKeys;
|
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.NumericQueryNode;
|
||||||
import org.apache.lucene.queryparser.flexible.standard.nodes.NumericRangeQueryNode;
|
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 NumericRangeQueryNode}s. It looks for
|
||||||
* {@link ConfigurationKeys#NUMERIC_CONFIG} set in the {@link FieldConfig} of
|
* {@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 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}.
|
* {@link NumericRangeQueryNode}.
|
||||||
*
|
*
|
||||||
* @see ConfigurationKeys#NUMERIC_CONFIG
|
* @see ConfigurationKeys#NUMERIC_CONFIG
|
||||||
* @see ParametricRangeQueryNode
|
* @see TermRangeQueryNode
|
||||||
* @see NumericConfig
|
* @see NumericConfig
|
||||||
* @see NumericRangeQueryNode
|
* @see NumericRangeQueryNode
|
||||||
*/
|
*/
|
||||||
|
@ -64,13 +63,13 @@ public class NumericRangeQueryNodeProcessor extends QueryNodeProcessorImpl {
|
||||||
@Override
|
@Override
|
||||||
protected QueryNode postProcessNode(QueryNode node) throws QueryNodeException {
|
protected QueryNode postProcessNode(QueryNode node) throws QueryNodeException {
|
||||||
|
|
||||||
if (node instanceof ParametricRangeQueryNode) {
|
if (node instanceof TermRangeQueryNode) {
|
||||||
QueryConfigHandler config = getQueryConfigHandler();
|
QueryConfigHandler config = getQueryConfigHandler();
|
||||||
|
|
||||||
if (config != null) {
|
if (config != null) {
|
||||||
ParametricRangeQueryNode parametricRangeNode = (ParametricRangeQueryNode) node;
|
TermRangeQueryNode termRangeNode = (TermRangeQueryNode) node;
|
||||||
FieldConfig fieldConfig = config.getFieldConfig(StringUtils
|
FieldConfig fieldConfig = config.getFieldConfig(StringUtils
|
||||||
.toString(parametricRangeNode.getField()));
|
.toString(termRangeNode.getField()));
|
||||||
|
|
||||||
if (fieldConfig != null) {
|
if (fieldConfig != null) {
|
||||||
|
|
||||||
|
@ -79,8 +78,8 @@ public class NumericRangeQueryNodeProcessor extends QueryNodeProcessorImpl {
|
||||||
|
|
||||||
if (numericConfig != null) {
|
if (numericConfig != null) {
|
||||||
|
|
||||||
ParametricQueryNode lower = parametricRangeNode.getLowerBound();
|
FieldQueryNode lower = termRangeNode.getLowerBound();
|
||||||
ParametricQueryNode upper = parametricRangeNode.getUpperBound();
|
FieldQueryNode upper = termRangeNode.getUpperBound();
|
||||||
|
|
||||||
String lowerText = lower.getTextAsString();
|
String lowerText = lower.getTextAsString();
|
||||||
String upperText = upper.getTextAsString();
|
String upperText = upper.getTextAsString();
|
||||||
|
@ -134,14 +133,12 @@ public class NumericRangeQueryNodeProcessor extends QueryNodeProcessorImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
NumericQueryNode lowerNode = new NumericQueryNode(
|
NumericQueryNode lowerNode = new NumericQueryNode(
|
||||||
parametricRangeNode.getField(), lowerNumber, numberFormat);
|
termRangeNode.getField(), lowerNumber, numberFormat);
|
||||||
NumericQueryNode upperNode = new NumericQueryNode(
|
NumericQueryNode upperNode = new NumericQueryNode(
|
||||||
parametricRangeNode.getField(), upperNumber, numberFormat);
|
termRangeNode.getField(), upperNumber, numberFormat);
|
||||||
|
|
||||||
boolean upperInclusive = upper == null
|
boolean lowerInclusive = termRangeNode.isLowerInclusive();
|
||||||
| upper.getOperator() == CompareOperator.LE;
|
boolean upperInclusive = termRangeNode.isUpperInclusive();
|
||||||
boolean lowerInclusive = lower == null
|
|
||||||
| lower.getOperator() == CompareOperator.GE;
|
|
||||||
|
|
||||||
return new NumericRangeQueryNode(lowerNode, upperNode,
|
return new NumericRangeQueryNode(lowerNode, upperNode,
|
||||||
lowerInclusive, upperInclusive, numericConfig);
|
lowerInclusive, upperInclusive, numericConfig);
|
||||||
|
|
|
@ -3,11 +3,11 @@ package org.apache.lucene.queryparser.flexible.standard.processors;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.lucene.queryparser.flexible.core.QueryNodeException;
|
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.FieldQueryNode;
|
||||||
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.QueryNode;
|
||||||
import org.apache.lucene.queryparser.flexible.core.processors.QueryNodeProcessorImpl;
|
import org.apache.lucene.queryparser.flexible.core.processors.QueryNodeProcessorImpl;
|
||||||
import org.apache.lucene.queryparser.flexible.core.util.UnescapedCharSequence;
|
import org.apache.lucene.queryparser.flexible.core.util.UnescapedCharSequence;
|
||||||
|
import org.apache.lucene.queryparser.flexible.standard.nodes.TermRangeQueryNode;
|
||||||
|
|
||||||
public class OpenRangeQueryNodeProcessor extends QueryNodeProcessorImpl {
|
public class OpenRangeQueryNodeProcessor extends QueryNodeProcessorImpl {
|
||||||
|
|
||||||
|
@ -18,10 +18,10 @@ public class OpenRangeQueryNodeProcessor extends QueryNodeProcessorImpl {
|
||||||
@Override
|
@Override
|
||||||
protected QueryNode postProcessNode(QueryNode node) throws QueryNodeException {
|
protected QueryNode postProcessNode(QueryNode node) throws QueryNodeException {
|
||||||
|
|
||||||
if (node instanceof ParametricRangeQueryNode) {
|
if (node instanceof TermRangeQueryNode) {
|
||||||
ParametricRangeQueryNode rangeNode = (ParametricRangeQueryNode) node;
|
TermRangeQueryNode rangeNode = (TermRangeQueryNode) node;
|
||||||
ParametricQueryNode lowerNode = (ParametricQueryNode) rangeNode.getLowerBound();
|
FieldQueryNode lowerNode = (FieldQueryNode) rangeNode.getLowerBound();
|
||||||
ParametricQueryNode upperNode = (ParametricQueryNode) rangeNode.getUpperBound();
|
FieldQueryNode upperNode = (FieldQueryNode) rangeNode.getUpperBound();
|
||||||
CharSequence lowerText = lowerNode.getText();
|
CharSequence lowerText = lowerNode.getText();
|
||||||
CharSequence upperText = upperNode.getText();
|
CharSequence upperText = upperNode.getText();
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class StandardQueryNodeProcessorPipeline extends
|
||||||
add(new NumericQueryNodeProcessor());
|
add(new NumericQueryNodeProcessor());
|
||||||
add(new NumericRangeQueryNodeProcessor());
|
add(new NumericRangeQueryNodeProcessor());
|
||||||
add(new LowercaseExpandedTermsQueryNodeProcessor());
|
add(new LowercaseExpandedTermsQueryNodeProcessor());
|
||||||
add(new ParametricRangeQueryNodeProcessor());
|
add(new TermRangeQueryNodeProcessor());
|
||||||
add(new AllowLeadingWildcardProcessor());
|
add(new AllowLeadingWildcardProcessor());
|
||||||
add(new AnalyzerQueryNodeProcessor());
|
add(new AnalyzerQueryNodeProcessor());
|
||||||
add(new PhraseSlopQueryNodeProcessor());
|
add(new PhraseSlopQueryNodeProcessor());
|
||||||
|
|
|
@ -28,21 +28,18 @@ import org.apache.lucene.document.DateTools.Resolution;
|
||||||
import org.apache.lucene.queryparser.flexible.core.QueryNodeException;
|
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.FieldConfig;
|
||||||
import org.apache.lucene.queryparser.flexible.core.config.QueryConfigHandler;
|
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.FieldQueryNode;
|
||||||
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.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.processors.QueryNodeProcessorImpl;
|
||||||
import org.apache.lucene.queryparser.flexible.standard.config.StandardQueryConfigHandler.ConfigurationKeys;
|
import org.apache.lucene.queryparser.flexible.standard.config.StandardQueryConfigHandler.ConfigurationKeys;
|
||||||
import org.apache.lucene.queryparser.flexible.standard.nodes.TermRangeQueryNode;
|
import org.apache.lucene.queryparser.flexible.standard.nodes.TermRangeQueryNode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This processor converts {@link ParametricRangeQueryNode} objects to
|
* This processors process {@link TermRangeQueryNode}s. It reads the lower and
|
||||||
* {@link TermRangeQueryNode} objects. It reads the lower and upper bounds value
|
* upper bounds value from the {@link TermRangeQueryNode} object and try
|
||||||
* from the {@link ParametricRangeQueryNode} object and try to parse their
|
* to parse their values using a {@link DateFormat}. If the values cannot be
|
||||||
* values using a {@link DateFormat}. If the values cannot be parsed to a date
|
* parsed to a date value, it will only create the {@link TermRangeQueryNode}
|
||||||
* value, it will only create the {@link TermRangeQueryNode} using the
|
* using the non-parsed values. <br/>
|
||||||
* non-parsed values. <br/>
|
|
||||||
* <br/>
|
* <br/>
|
||||||
* If a {@link ConfigurationKeys#LOCALE} is defined in the
|
* If a {@link ConfigurationKeys#LOCALE} is defined in the
|
||||||
* {@link QueryConfigHandler} it will be used to parse the date, otherwise
|
* {@link QueryConfigHandler} it will be used to parse the date, otherwise
|
||||||
|
@ -56,21 +53,20 @@ import org.apache.lucene.queryparser.flexible.standard.nodes.TermRangeQueryNode;
|
||||||
* @see ConfigurationKeys#DATE_RESOLUTION
|
* @see ConfigurationKeys#DATE_RESOLUTION
|
||||||
* @see ConfigurationKeys#LOCALE
|
* @see ConfigurationKeys#LOCALE
|
||||||
* @see TermRangeQueryNode
|
* @see TermRangeQueryNode
|
||||||
* @see ParametricRangeQueryNode
|
|
||||||
*/
|
*/
|
||||||
public class ParametricRangeQueryNodeProcessor extends QueryNodeProcessorImpl {
|
public class TermRangeQueryNodeProcessor extends QueryNodeProcessorImpl {
|
||||||
|
|
||||||
public ParametricRangeQueryNodeProcessor() {
|
public TermRangeQueryNodeProcessor() {
|
||||||
// empty constructor
|
// empty constructor
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected QueryNode postProcessNode(QueryNode node) throws QueryNodeException {
|
protected QueryNode postProcessNode(QueryNode node) throws QueryNodeException {
|
||||||
|
|
||||||
if (node instanceof ParametricRangeQueryNode) {
|
if (node instanceof TermRangeQueryNode) {
|
||||||
ParametricRangeQueryNode parametricRangeNode = (ParametricRangeQueryNode) node;
|
TermRangeQueryNode termRangeNode = (TermRangeQueryNode) node;
|
||||||
ParametricQueryNode upper = parametricRangeNode.getUpperBound();
|
FieldQueryNode upper = termRangeNode.getUpperBound();
|
||||||
ParametricQueryNode lower = parametricRangeNode.getLowerBound();
|
FieldQueryNode lower = termRangeNode.getLowerBound();
|
||||||
|
|
||||||
DateTools.Resolution dateRes = null;
|
DateTools.Resolution dateRes = null;
|
||||||
boolean inclusive = false;
|
boolean inclusive = false;
|
||||||
|
@ -80,7 +76,7 @@ public class ParametricRangeQueryNodeProcessor extends QueryNodeProcessorImpl {
|
||||||
locale = Locale.getDefault();
|
locale = Locale.getDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
CharSequence field = parametricRangeNode.getField();
|
CharSequence field = termRangeNode.getField();
|
||||||
String fieldStr = null;
|
String fieldStr = null;
|
||||||
|
|
||||||
if (field != null) {
|
if (field != null) {
|
||||||
|
@ -94,7 +90,7 @@ public class ParametricRangeQueryNodeProcessor extends QueryNodeProcessorImpl {
|
||||||
dateRes = fieldConfig.get(ConfigurationKeys.DATE_RESOLUTION);
|
dateRes = fieldConfig.get(ConfigurationKeys.DATE_RESOLUTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (upper.getOperator() == CompareOperator.LE) {
|
if (termRangeNode.isUpperInclusive()) {
|
||||||
inclusive = true;
|
inclusive = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,10 +132,6 @@ public class ParametricRangeQueryNodeProcessor extends QueryNodeProcessorImpl {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
return new TermRangeQueryNode(lower, upper, part1.length() == 0
|
|
||||||
| lower.getOperator() == CompareOperator.GE, part2.length() == 0
|
|
||||||
| upper.getOperator() == CompareOperator.LE);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return node;
|
return node;
|
|
@ -22,12 +22,12 @@ import java.util.List;
|
||||||
import org.apache.lucene.queryparser.flexible.core.QueryNodeException;
|
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.FieldQueryNode;
|
||||||
import org.apache.lucene.queryparser.flexible.core.nodes.FuzzyQueryNode;
|
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.QueryNode;
|
||||||
import org.apache.lucene.queryparser.flexible.core.nodes.QuotedFieldQueryNode;
|
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.processors.QueryNodeProcessorImpl;
|
||||||
import org.apache.lucene.queryparser.flexible.core.util.UnescapedCharSequence;
|
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.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.nodes.WildcardQueryNode;
|
||||||
import org.apache.lucene.queryparser.flexible.standard.parser.StandardSyntaxParser;
|
import org.apache.lucene.queryparser.flexible.standard.parser.StandardSyntaxParser;
|
||||||
import org.apache.lucene.search.PrefixQuery;
|
import org.apache.lucene.search.PrefixQuery;
|
||||||
|
@ -57,9 +57,9 @@ public class WildcardQueryNodeProcessor extends QueryNodeProcessorImpl {
|
||||||
FieldQueryNode fqn = (FieldQueryNode) node;
|
FieldQueryNode fqn = (FieldQueryNode) node;
|
||||||
CharSequence text = fqn.getText();
|
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
|
// QuotedFieldQueryNode to reproduce the old parser behavior
|
||||||
if (fqn instanceof ParametricQueryNode
|
if (fqn.getParent() instanceof TermRangeQueryNode
|
||||||
|| fqn instanceof QuotedFieldQueryNode
|
|| fqn instanceof QuotedFieldQueryNode
|
||||||
|| text.length() <= 0){
|
|| text.length() <= 0){
|
||||||
// Ignore empty terms
|
// Ignore empty terms
|
||||||
|
|
Loading…
Reference in New Issue