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