mirror of https://github.com/apache/lucene.git
LUCENE-1768: Javadocs (week-8)
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1150671 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
de074e9535
commit
b6c1db99d3
|
@ -17,6 +17,14 @@ package org.apache.lucene.queryparser.flexible.core.nodes;
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
public interface FieldValuePairQueryNode<T extends Object> extends FieldableNode, ValueQueryNode<T> {
|
||||
/**
|
||||
* This interface should be implemented by {@link QueryNode} that holds a field
|
||||
* and an arbitrary value.
|
||||
*
|
||||
* @see FieldableNode
|
||||
* @see ValueQueryNode
|
||||
*/
|
||||
public interface FieldValuePairQueryNode<T extends Object> extends
|
||||
FieldableNode, ValueQueryNode<T> {
|
||||
|
||||
}
|
||||
|
|
|
@ -1,26 +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.
|
||||
*/
|
||||
|
||||
public interface NumberQueryNode {
|
||||
|
||||
void setNumber(Number number);
|
||||
|
||||
Number getNumber();
|
||||
|
||||
}
|
|
@ -17,6 +17,10 @@ package org.apache.lucene.queryparser.flexible.core.nodes;
|
|||
* the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* This interface should be implemented by {@link QueryNode} that holds an
|
||||
* arbitrary value.
|
||||
*/
|
||||
public interface ValueQueryNode<T extends Object> extends QueryNode {
|
||||
|
||||
public void setValue(T value);
|
||||
|
|
|
@ -61,6 +61,7 @@ Grouping nodes:
|
|||
<li>FuzzyQueryNode - fuzzy node</li>
|
||||
<li>ParametricRangeQueryNode - 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>
|
||||
</ul>
|
||||
</p>
|
||||
|
@ -68,6 +69,7 @@ Grouping nodes:
|
|||
Leaf Nodes:
|
||||
<ul>
|
||||
<li>FieldQueryNode - field/value node</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>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>
|
||||
|
|
|
@ -18,19 +18,32 @@ package org.apache.lucene.queryparser.flexible.standard.builders;
|
|||
*/
|
||||
|
||||
import org.apache.lucene.queryparser.flexible.core.QueryNodeException;
|
||||
import org.apache.lucene.queryparser.flexible.core.builders.QueryTreeBuilder;
|
||||
import org.apache.lucene.queryparser.flexible.core.nodes.FieldQueryNode;
|
||||
import org.apache.lucene.queryparser.flexible.core.nodes.QueryNode;
|
||||
import org.apache.lucene.search.TermQuery;
|
||||
|
||||
/**
|
||||
* Builds a {@link TermQuery} object from a {@link FieldQueryNode} object.
|
||||
* This builder does nothing. Commonly used for {@link QueryNode} objects that
|
||||
* are built by its parent's builder.
|
||||
*
|
||||
* @see StandardQueryBuilder
|
||||
* @see QueryTreeBuilder
|
||||
*/
|
||||
public class DummyQueryNodeBuilder implements StandardQueryBuilder {
|
||||
|
||||
/**
|
||||
* Constructs a {@link DummyQueryNodeBuilder} object.
|
||||
*/
|
||||
public DummyQueryNodeBuilder() {
|
||||
// empty constructor
|
||||
}
|
||||
|
||||
/**
|
||||
* Always return <code>null</code>.
|
||||
*
|
||||
* return <code>null</code>
|
||||
*/
|
||||
public TermQuery build(QueryNode queryNode) throws QueryNodeException {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -28,8 +28,17 @@ import org.apache.lucene.queryparser.flexible.standard.nodes.NumericQueryNode;
|
|||
import org.apache.lucene.queryparser.flexible.standard.nodes.NumericRangeQueryNode;
|
||||
import org.apache.lucene.search.NumericRangeQuery;
|
||||
|
||||
/**
|
||||
* Builds {@link NumericRangeQuery}s out of {@link NumericRangeQueryNode}s.
|
||||
*
|
||||
* @see NumericRangeQuery
|
||||
* @see NumericRangeQueryNode
|
||||
*/
|
||||
public class NumericRangeQueryNodeBuilder implements StandardQueryBuilder {
|
||||
|
||||
/**
|
||||
* Constructs a {@link NumericRangeQueryNodeBuilder} object.
|
||||
*/
|
||||
public NumericRangeQueryNodeBuilder() {
|
||||
// empty constructor
|
||||
}
|
||||
|
|
|
@ -19,16 +19,27 @@ package org.apache.lucene.queryparser.flexible.standard.config;
|
|||
|
||||
import java.text.DateFormat;
|
||||
import java.text.FieldPosition;
|
||||
import java.text.Format;
|
||||
import java.text.NumberFormat;
|
||||
import java.text.ParsePosition;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* This {@link Format} parses {@link Long} into date strings and vice-versa. It
|
||||
* uses the given {@link DateFormat} to parse and format dates, but before, it
|
||||
* converts {@link Long} to {@link Date} objects or vice-versa.
|
||||
*/
|
||||
public class NumberDateFormat extends NumberFormat {
|
||||
|
||||
private static final long serialVersionUID = 964823936071308283L;
|
||||
|
||||
final private DateFormat dateFormat;
|
||||
|
||||
/**
|
||||
* Constructs a {@link NumberDateFormat} object using the given {@link DateFormat}.
|
||||
*
|
||||
* @param dateFormat {@link DateFormat} used to parse and format dates
|
||||
*/
|
||||
public NumberDateFormat(DateFormat dateFormat) {
|
||||
this.dateFormat = dateFormat;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,15 @@ package org.apache.lucene.queryparser.flexible.standard.config;
|
|||
import java.text.NumberFormat;
|
||||
|
||||
import org.apache.lucene.document.NumericField;
|
||||
import org.apache.lucene.search.NumericRangeQuery;
|
||||
|
||||
/**
|
||||
* This class holds the configuration used to parse numeric queries and create
|
||||
* {@link NumericRangeQuery}s.
|
||||
*
|
||||
* @see NumericRangeQuery
|
||||
* @see NumberFormat
|
||||
*/
|
||||
public class NumericConfig {
|
||||
|
||||
private int precisionStep;
|
||||
|
@ -28,30 +36,78 @@ public class NumericConfig {
|
|||
private NumberFormat format;
|
||||
|
||||
private NumericField.DataType type;
|
||||
|
||||
public NumericConfig(int precisionStep, NumberFormat format, NumericField.DataType type) {
|
||||
|
||||
/**
|
||||
* Constructs a {@link NumericConfig} object.
|
||||
*
|
||||
* @param precisionStep
|
||||
* the precision used to index the numeric values
|
||||
* @param format
|
||||
* the {@link NumberFormat} used to parse a {@link String} to
|
||||
* {@link Number}
|
||||
* @param type
|
||||
* the numeric type used to index the numeric values
|
||||
*
|
||||
* @see NumericConfig#setPrecisionStep(int)
|
||||
* @see NumericConfig#setNumberFormat(NumberFormat)
|
||||
* @see #setType(org.apache.lucene.document.NumericField.DataType)
|
||||
*/
|
||||
public NumericConfig(int precisionStep, NumberFormat format,
|
||||
NumericField.DataType type) {
|
||||
setPrecisionStep(precisionStep);
|
||||
setNumberFormat(format);
|
||||
setType(type);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the precision used to index the numeric values
|
||||
*
|
||||
* @return the precision used to index the numeric values
|
||||
*
|
||||
* @see NumericRangeQuery#getPrecisionStep()
|
||||
*/
|
||||
public int getPrecisionStep() {
|
||||
return precisionStep;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the precision used to index the numeric values
|
||||
*
|
||||
* @param precisionStep
|
||||
* the precision used to index the numeric values
|
||||
*
|
||||
* @see NumericRangeQuery#getPrecisionStep()
|
||||
*/
|
||||
public void setPrecisionStep(int precisionStep) {
|
||||
this.precisionStep = precisionStep;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link NumberFormat} used to parse a {@link String} to
|
||||
* {@link Number}
|
||||
*
|
||||
* @return the {@link NumberFormat} used to parse a {@link String} to
|
||||
* {@link Number}
|
||||
*/
|
||||
public NumberFormat getNumberFormat() {
|
||||
return format;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the numeric type used to index the numeric values
|
||||
*
|
||||
* @return the numeric type used to index the numeric values
|
||||
*/
|
||||
public NumericField.DataType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the numeric type used to index the numeric values
|
||||
*
|
||||
* @param type the numeric type used to index the numeric values
|
||||
*/
|
||||
public void setType(NumericField.DataType type) {
|
||||
|
||||
if (type == null) {
|
||||
|
@ -61,7 +117,15 @@ public class NumericConfig {
|
|||
this.type = type;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the {@link NumberFormat} used to parse a {@link String} to
|
||||
* {@link Number}
|
||||
*
|
||||
* @param format
|
||||
* the {@link NumberFormat} used to parse a {@link String} to
|
||||
* {@link Number}, cannot be <code>null</code>
|
||||
*/
|
||||
public void setNumberFormat(NumberFormat format) {
|
||||
|
||||
if (format == null) {
|
||||
|
@ -81,7 +145,8 @@ public class NumericConfig {
|
|||
NumericConfig other = (NumericConfig) obj;
|
||||
|
||||
if (this.precisionStep == other.precisionStep
|
||||
&& this.format == other.format) {
|
||||
&& this.type == other.type
|
||||
&& (this.format == other.format || (this.format.equals(other.format)))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,10 +24,26 @@ import org.apache.lucene.queryparser.flexible.core.config.FieldConfigListener;
|
|||
import org.apache.lucene.queryparser.flexible.core.config.QueryConfigHandler;
|
||||
import org.apache.lucene.queryparser.flexible.standard.config.StandardQueryConfigHandler.ConfigurationKeys;
|
||||
|
||||
/**
|
||||
* This listener is used to listen to {@link FieldConfig} requests in
|
||||
* {@link QueryConfigHandler} and add {@link ConfigurationKeys#NUMERIC_CONFIG}
|
||||
* based on the {@link ConfigurationKeys#NUMERIC_CONFIG_MAP} set in the
|
||||
* {@link QueryConfigHandler}.
|
||||
*
|
||||
* @see NumericConfig
|
||||
* @see QueryConfigHandler
|
||||
* @see ConfigurationKeys#NUMERIC_CONFIG
|
||||
* @see ConfigurationKeys#NUMERIC_CONFIG_MAP
|
||||
*/
|
||||
public class NumericFieldConfigListener implements FieldConfigListener {
|
||||
|
||||
final private QueryConfigHandler config;
|
||||
|
||||
/**
|
||||
* Construcs a {@link NumericFieldConfigListener} object using the given {@link QueryConfigHandler}.
|
||||
*
|
||||
* @param config the {@link QueryConfigHandler} it will listen too
|
||||
*/
|
||||
public NumericFieldConfigListener(QueryConfigHandler config) {
|
||||
|
||||
if (config == null) {
|
||||
|
|
|
@ -26,16 +26,32 @@ import org.apache.lucene.queryparser.flexible.core.nodes.QueryNodeImpl;
|
|||
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)
|
||||
*/
|
||||
public abstract class AbstractRangeQueryNode<T extends FieldValuePairQueryNode<?>>
|
||||
extends QueryNodeImpl implements FieldableNode {
|
||||
|
||||
private boolean lowerInclusive, upperInclusive;
|
||||
|
||||
/**
|
||||
* Constructs an {@link AbstractRangeQueryNode}, it should be invoked only by
|
||||
* its extenders.
|
||||
*/
|
||||
protected AbstractRangeQueryNode() {
|
||||
setLeaf(false);
|
||||
allocate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the field associated with this node.
|
||||
*
|
||||
* @return the field associated with this node
|
||||
*
|
||||
* @see FieldableNode
|
||||
*/
|
||||
public CharSequence getField() {
|
||||
CharSequence field = null;
|
||||
T lower = getLowerBound();
|
||||
|
@ -52,6 +68,11 @@ public abstract class AbstractRangeQueryNode<T extends FieldValuePairQueryNode<?
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the field associated with this node.
|
||||
*
|
||||
* @param fieldName the field associated with this node
|
||||
*/
|
||||
public void setField(CharSequence fieldName) {
|
||||
T lower = getLowerBound();
|
||||
T upper = getUpperBound();
|
||||
|
@ -66,24 +87,57 @@ public abstract class AbstractRangeQueryNode<T extends FieldValuePairQueryNode<?
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the lower bound node.
|
||||
*
|
||||
* @return the lower bound node.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public T getLowerBound() {
|
||||
return (T) getChildren().get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the upper bound node.
|
||||
*
|
||||
* @return the upper bound node.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public T getUpperBound() {
|
||||
return (T) getChildren().get(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the lower bound is inclusive or exclusive.
|
||||
*
|
||||
* @return <code>true</code> if the lower bound is inclusive, otherwise, <code>false</code>
|
||||
*/
|
||||
public boolean isLowerInclusive() {
|
||||
return lowerInclusive;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the upper bound is inclusive or exclusive.
|
||||
*
|
||||
* @return <code>true</code> if the upper bound is inclusive, otherwise, <code>false</code>
|
||||
*/
|
||||
public boolean isUpperInclusive() {
|
||||
return upperInclusive;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the lower and upper bounds.
|
||||
*
|
||||
* @param lower the lower bound, <code>null</code> if lower bound is open
|
||||
* @param upper the upper bound, <code>null</code> if upper bound is open
|
||||
* @param lowerInclusive <code>true</code> if the lower bound is inclusive, otherwise, <code>false</code>
|
||||
* @param upperInclusive <code>true</code> if the upper bound is inclusive, otherwise, <code>false</code>
|
||||
*
|
||||
* @see #getLowerBound()
|
||||
* @see #getUpperBound()
|
||||
* @see #isLowerInclusive()
|
||||
* @see #isUpperInclusive()
|
||||
*/
|
||||
public void setBounds(T lower, T upper, boolean lowerInclusive,
|
||||
boolean upperInclusive) {
|
||||
|
||||
|
|
|
@ -20,11 +20,20 @@ package org.apache.lucene.queryparser.flexible.standard.nodes;
|
|||
import java.text.NumberFormat;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.apache.lucene.queryparser.flexible.core.nodes.FieldQueryNode;
|
||||
import org.apache.lucene.queryparser.flexible.core.nodes.FieldValuePairQueryNode;
|
||||
import org.apache.lucene.queryparser.flexible.core.nodes.QueryNodeImpl;
|
||||
import org.apache.lucene.queryparser.flexible.core.parser.EscapeQuerySyntax;
|
||||
import org.apache.lucene.queryparser.flexible.core.parser.EscapeQuerySyntax.Type;
|
||||
import org.apache.lucene.queryparser.flexible.standard.config.NumericConfig;
|
||||
|
||||
/**
|
||||
* This query node represents a field query that holds a numeric value. It is
|
||||
* similar to {@link FieldQueryNode}, however the {@link #getValue()} returns a
|
||||
* {@link Number}.
|
||||
*
|
||||
* @see NumericConfig
|
||||
*/
|
||||
public class NumericQueryNode extends QueryNodeImpl implements
|
||||
FieldValuePairQueryNode<Number> {
|
||||
|
||||
|
@ -34,6 +43,15 @@ public class NumericQueryNode extends QueryNodeImpl implements
|
|||
|
||||
private Number value;
|
||||
|
||||
/**
|
||||
* Creates a {@link NumericQueryNode} object using the given field,
|
||||
* {@link Number} value and {@link NumberFormat} used to convert the value to
|
||||
* {@link String}.
|
||||
*
|
||||
* @param field the field associated with this query node
|
||||
* @param value the value hold by this node
|
||||
* @param numberFormat the {@link NumberFormat} used to convert the value to {@link String}
|
||||
*/
|
||||
public NumericQueryNode(CharSequence field, Number value,
|
||||
NumberFormat numberFormat) {
|
||||
|
||||
|
@ -45,14 +63,32 @@ public class NumericQueryNode extends QueryNodeImpl implements
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the field associated with this node.
|
||||
*
|
||||
* @return the field associated with this node
|
||||
*/
|
||||
public CharSequence getField() {
|
||||
return this.field;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the field associated with this node.
|
||||
*
|
||||
* @param fieldName the field associated with this node
|
||||
*/
|
||||
public void setField(CharSequence fieldName) {
|
||||
this.field = fieldName;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used to get the value converted to {@link String} and
|
||||
* escaped using the given {@link EscapeQuerySyntax}.
|
||||
*
|
||||
* @param escaper the {@link EscapeQuerySyntax} used to escape the value {@link String}
|
||||
*
|
||||
* @return the value converte to {@link String} and escaped
|
||||
*/
|
||||
protected CharSequence getTermEscaped(EscapeQuerySyntax escaper) {
|
||||
return escaper.escape(NumberFormat.getNumberInstance().format(this.value),
|
||||
Locale.ENGLISH, Type.NORMAL);
|
||||
|
@ -66,18 +102,38 @@ public class NumericQueryNode extends QueryNodeImpl implements
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the {@link NumberFormat} used to convert the value to {@link String}.
|
||||
*
|
||||
* @param format the {@link NumberFormat} used to convert the value to {@link String}
|
||||
*/
|
||||
public void setNumberFormat(NumberFormat format) {
|
||||
this.numberFormat = format;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link NumberFormat} used to convert the value to {@link String}.
|
||||
*
|
||||
* @return the {@link NumberFormat} used to convert the value to {@link String}
|
||||
*/
|
||||
public NumberFormat getNumberFormat() {
|
||||
return this.numberFormat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the numeric value as {@link Number}.
|
||||
*
|
||||
* @return the numeric value
|
||||
*/
|
||||
public Number getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the numeric value.
|
||||
*
|
||||
* @param value the numeric value
|
||||
*/
|
||||
public void setValue(Number value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import org.apache.lucene.document.NumericField;
|
|||
import org.apache.lucene.messages.MessageImpl;
|
||||
import org.apache.lucene.queryparser.flexible.core.QueryNodeException;
|
||||
import org.apache.lucene.queryparser.flexible.core.messages.QueryParserMessages;
|
||||
import org.apache.lucene.queryparser.flexible.core.nodes.FieldQueryNode;
|
||||
import org.apache.lucene.queryparser.flexible.standard.config.NumericConfig;
|
||||
|
||||
/**
|
||||
|
@ -23,11 +24,30 @@ import org.apache.lucene.queryparser.flexible.standard.config.NumericConfig;
|
|||
* the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* This query node represents a range query composed by {@link NumericQueryNode}
|
||||
* bounds, which means the bound values are {@link Number}s.
|
||||
*
|
||||
* @see NumericQueryNode
|
||||
* @see AbstractRangeQueryNode
|
||||
*/
|
||||
public class NumericRangeQueryNode extends
|
||||
AbstractRangeQueryNode<NumericQueryNode> {
|
||||
|
||||
public NumericConfig numericConfig;
|
||||
|
||||
/**
|
||||
* Constructs a {@link NumericRangeQueryNode} object using the given
|
||||
* {@link NumericQueryNode} as its bounds and {@link NumericConfig}.
|
||||
*
|
||||
* @param lower the lower bound
|
||||
* @param upper the upper bound
|
||||
* @param lowerInclusive <code>true</code> if the lower bound is inclusive, otherwise, <code>false</code>
|
||||
* @param upperInclusive <code>true</code> if the upper bound is inclusive, otherwise, <code>false</code>
|
||||
* @param numericConfig the {@link NumericConfig} that represents associated with the upper and lower bounds
|
||||
*
|
||||
* @see #setBounds(NumericQueryNode, NumericQueryNode, boolean, boolean, NumericConfig)
|
||||
*/
|
||||
public NumericRangeQueryNode(NumericQueryNode lower, NumericQueryNode upper,
|
||||
boolean lowerInclusive, boolean upperInclusive, NumericConfig numericConfig) throws QueryNodeException {
|
||||
setBounds(lower, upper, lowerInclusive, upperInclusive, numericConfig);
|
||||
|
@ -52,6 +72,17 @@ public class NumericRangeQueryNode extends
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the upper and lower bounds of this range query node and the
|
||||
* {@link NumericConfig} associated with these bounds.
|
||||
*
|
||||
* @param lower the lower bound
|
||||
* @param upper the upper bound
|
||||
* @param lowerInclusive <code>true</code> if the lower bound is inclusive, otherwise, <code>false</code>
|
||||
* @param upperInclusive <code>true</code> if the upper bound is inclusive, otherwise, <code>false</code>
|
||||
* @param numericConfig the {@link NumericConfig} that represents associated with the upper and lower bounds
|
||||
*
|
||||
*/
|
||||
public void setBounds(NumericQueryNode lower, NumericQueryNode upper,
|
||||
boolean lowerInclusive, boolean upperInclusive, NumericConfig numericConfig) throws QueryNodeException {
|
||||
|
||||
|
@ -92,6 +123,11 @@ public class NumericRangeQueryNode extends
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link NumericConfig} associated with the lower and upper bounds.
|
||||
*
|
||||
* @return the {@link NumericConfig} associated with the lower and upper bounds
|
||||
*/
|
||||
public NumericConfig getNumericConfig() {
|
||||
return this.numericConfig;
|
||||
}
|
||||
|
|
|
@ -20,13 +20,23 @@ package org.apache.lucene.queryparser.flexible.standard.nodes;
|
|||
import org.apache.lucene.queryparser.flexible.core.nodes.FieldQueryNode;
|
||||
|
||||
/**
|
||||
* This query node represents a range query.
|
||||
* This query node represents a range query composed by {@link FieldQueryNode}
|
||||
* bounds, which means the bound values are strings.
|
||||
*
|
||||
* @see org.apache.lucene.queryparser.flexible.standard.processors.ParametricRangeQueryNodeProcessor
|
||||
* @see org.apache.lucene.search.TermRangeQuery
|
||||
* @see FieldQueryNode
|
||||
* @see AbstractRangeQueryNode
|
||||
*/
|
||||
public class TermRangeQueryNode extends AbstractRangeQueryNode<FieldQueryNode> {
|
||||
|
||||
/**
|
||||
* Constructs a {@link TermRangeQueryNode} object using the given
|
||||
* {@link FieldQueryNode} as its bounds.
|
||||
*
|
||||
* @param lower the lower bound
|
||||
* @param upper the upper bound
|
||||
* @param lowerInclusive <code>true</code> if the lower bound is inclusive, otherwise, <code>false</code>
|
||||
* @param upperInclusive <code>true</code> if the upper bound is inclusive, otherwise, <code>false</code>
|
||||
*/
|
||||
public TermRangeQueryNode(FieldQueryNode lower, FieldQueryNode upper,
|
||||
boolean lowerInclusive, boolean upperInclusive) {
|
||||
setBounds(lower, upper, lowerInclusive, upperInclusive);
|
||||
|
|
|
@ -36,8 +36,31 @@ import org.apache.lucene.queryparser.flexible.standard.config.StandardQueryConfi
|
|||
import org.apache.lucene.queryparser.flexible.standard.nodes.NumericQueryNode;
|
||||
import org.apache.lucene.queryparser.flexible.standard.nodes.NumericRangeQueryNode;
|
||||
|
||||
/**
|
||||
* This processor is used to convert {@link FieldQueryNode}s to
|
||||
* {@link NumericRangeQueryNode}s. It looks for
|
||||
* {@link ConfigurationKeys#NUMERIC_CONFIG} set in the {@link FieldConfig} of
|
||||
* every {@link FieldQueryNode} found. If
|
||||
* {@link ConfigurationKeys#NUMERIC_CONFIG} is found, it considers that
|
||||
* {@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/>
|
||||
* <br/>
|
||||
* Note that {@link ParametricQueryNode}s are ignored, even being a
|
||||
* {@link FieldQueryNode}.
|
||||
*
|
||||
* @see ConfigurationKeys#NUMERIC_CONFIG
|
||||
* @see FieldQueryNode
|
||||
* @see NumericConfig
|
||||
* @see NumericQueryNode
|
||||
*/
|
||||
public class NumericQueryNodeProcessor extends QueryNodeProcessorImpl {
|
||||
|
||||
/**
|
||||
* Constructs a {@link NumericQueryNodeProcessor} object.
|
||||
*/
|
||||
public NumericQueryNodeProcessor() {
|
||||
// empty constructor
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ 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.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;
|
||||
|
@ -38,8 +39,25 @@ import org.apache.lucene.queryparser.flexible.standard.config.StandardQueryConfi
|
|||
import org.apache.lucene.queryparser.flexible.standard.nodes.NumericQueryNode;
|
||||
import org.apache.lucene.queryparser.flexible.standard.nodes.NumericRangeQueryNode;
|
||||
|
||||
/**
|
||||
* This processor is used to convert {@link ParametricRangeQueryNode}s to
|
||||
* {@link NumericRangeQueryNode}s. It looks for
|
||||
* {@link ConfigurationKeys#NUMERIC_CONFIG} set in the {@link FieldConfig} of
|
||||
* every {@link ParametricRangeQueryNode} found. If
|
||||
* {@link ConfigurationKeys#NUMERIC_CONFIG} is found, it considers that
|
||||
* {@link ParametricRangeQueryNode} to be a numeric range query and convert it to
|
||||
* {@link NumericRangeQueryNode}.
|
||||
*
|
||||
* @see ConfigurationKeys#NUMERIC_CONFIG
|
||||
* @see ParametricRangeQueryNode
|
||||
* @see NumericConfig
|
||||
* @see NumericRangeQueryNode
|
||||
*/
|
||||
public class NumericRangeQueryNodeProcessor extends QueryNodeProcessorImpl {
|
||||
|
||||
/**
|
||||
* Constructs an empty {@link NumericRangeQueryNode} object.
|
||||
*/
|
||||
public NumericRangeQueryNodeProcessor() {
|
||||
// empty constructor
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ The package org.apache.lucene.queryparser.flexible.standard.processors contains
|
|||
that modifies the query node tree according to the actual Lucene queries.
|
||||
</p>
|
||||
<p>
|
||||
This processors are already assembled correctly in the StandardQueryNodeProcessorPipeline.
|
||||
These processors are already assembled correctly in the StandardQueryNodeProcessorPipeline.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in New Issue