Package org.apache.lucene.search
Class NumericRangeFilter<T extends Number>
- java.lang.Object
-
- org.apache.lucene.search.Filter
-
- org.apache.lucene.search.MultiTermQueryWrapperFilter<NumericRangeQuery<T>>
-
- org.apache.lucene.search.NumericRangeFilter<T>
-
public final class NumericRangeFilter<T extends Number> extends MultiTermQueryWrapperFilter<NumericRangeQuery<T>>
AFilterthat only accepts numeric values within a specified range. To use this, you must first index the numeric values usingIntField,FloatField,LongFieldorDoubleField(expert:NumericTokenStream).You create a new NumericRangeFilter with the static factory methods, eg:
Filter f = NumericRangeFilter.newFloatRange("weight", 0.03f, 0.10f, true, true);accepts all documents whose float valued "weight" field ranges from 0.03 to 0.10, inclusive. SeeNumericRangeQueryfor details on how Lucene indexes and searches numeric valued fields.- Since:
- 2.9
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description TgetMax()Returns the upper value of this range filterTgetMin()Returns the lower value of this range filterintgetPrecisionStep()Returns the precision step.booleanincludesMax()Returnstrueif the upper endpoint is inclusivebooleanincludesMin()Returnstrueif the lower endpoint is inclusivestatic NumericRangeFilter<Double>newDoubleRange(String field, int precisionStep, Double min, Double max, boolean minInclusive, boolean maxInclusive)Factory that creates aNumericRangeFilter, that filters adoublerange using the givenprecisionStep.static NumericRangeFilter<Double>newDoubleRange(String field, Double min, Double max, boolean minInclusive, boolean maxInclusive)Factory that creates aNumericRangeFilter, that queries adoublerange using the defaultprecisionStepNumericUtils.PRECISION_STEP_DEFAULT(4).static NumericRangeFilter<Float>newFloatRange(String field, int precisionStep, Float min, Float max, boolean minInclusive, boolean maxInclusive)Factory that creates aNumericRangeFilter, that filters afloatrange using the givenprecisionStep.static NumericRangeFilter<Float>newFloatRange(String field, Float min, Float max, boolean minInclusive, boolean maxInclusive)Factory that creates aNumericRangeFilter, that queries afloatrange using the defaultprecisionStepNumericUtils.PRECISION_STEP_DEFAULT(4).static NumericRangeFilter<Integer>newIntRange(String field, int precisionStep, Integer min, Integer max, boolean minInclusive, boolean maxInclusive)static NumericRangeFilter<Integer>newIntRange(String field, Integer min, Integer max, boolean minInclusive, boolean maxInclusive)Factory that creates aNumericRangeFilter, that queries aintrange using the defaultprecisionStepNumericUtils.PRECISION_STEP_DEFAULT(4).static NumericRangeFilter<Long>newLongRange(String field, int precisionStep, Long min, Long max, boolean minInclusive, boolean maxInclusive)static NumericRangeFilter<Long>newLongRange(String field, Long min, Long max, boolean minInclusive, boolean maxInclusive)Factory that creates aNumericRangeFilter, that queries alongrange using the defaultprecisionStepNumericUtils.PRECISION_STEP_DEFAULT(4).-
Methods inherited from class org.apache.lucene.search.MultiTermQueryWrapperFilter
equals, getDocIdSet, getField, hashCode, toString
-
-
-
-
Method Detail
-
newLongRange
public static NumericRangeFilter<Long> newLongRange(String field, int precisionStep, Long min, Long max, boolean minInclusive, boolean maxInclusive)
Factory that creates aNumericRangeFilter, that filters alongrange using the givenprecisionStep. You can have half-open ranges (which are in fact </≤ or >/≥ queries) by setting the min or max value tonull. By setting inclusive to false, it will match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
-
newLongRange
public static NumericRangeFilter<Long> newLongRange(String field, Long min, Long max, boolean minInclusive, boolean maxInclusive)
Factory that creates aNumericRangeFilter, that queries alongrange using the defaultprecisionStepNumericUtils.PRECISION_STEP_DEFAULT(4). You can have half-open ranges (which are in fact </≤ or >/≥ queries) by setting the min or max value tonull. By setting inclusive to false, it will match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
-
newIntRange
public static NumericRangeFilter<Integer> newIntRange(String field, int precisionStep, Integer min, Integer max, boolean minInclusive, boolean maxInclusive)
Factory that creates aNumericRangeFilter, that filters aintrange using the givenprecisionStep. You can have half-open ranges (which are in fact </≤ or >/≥ queries) by setting the min or max value tonull. By setting inclusive to false, it will match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
-
newIntRange
public static NumericRangeFilter<Integer> newIntRange(String field, Integer min, Integer max, boolean minInclusive, boolean maxInclusive)
Factory that creates aNumericRangeFilter, that queries aintrange using the defaultprecisionStepNumericUtils.PRECISION_STEP_DEFAULT(4). You can have half-open ranges (which are in fact </≤ or >/≥ queries) by setting the min or max value tonull. By setting inclusive to false, it will match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
-
newDoubleRange
public static NumericRangeFilter<Double> newDoubleRange(String field, int precisionStep, Double min, Double max, boolean minInclusive, boolean maxInclusive)
Factory that creates aNumericRangeFilter, that filters adoublerange using the givenprecisionStep. You can have half-open ranges (which are in fact </≤ or >/≥ queries) by setting the min or max value tonull.Double.NaNwill never match a half-open range, to hitNaNuse a query withmin == max == Double.NaN. By setting inclusive to false, it will match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
-
newDoubleRange
public static NumericRangeFilter<Double> newDoubleRange(String field, Double min, Double max, boolean minInclusive, boolean maxInclusive)
Factory that creates aNumericRangeFilter, that queries adoublerange using the defaultprecisionStepNumericUtils.PRECISION_STEP_DEFAULT(4). You can have half-open ranges (which are in fact </≤ or >/≥ queries) by setting the min or max value tonull.Double.NaNwill never match a half-open range, to hitNaNuse a query withmin == max == Double.NaN. By setting inclusive to false, it will match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
-
newFloatRange
public static NumericRangeFilter<Float> newFloatRange(String field, int precisionStep, Float min, Float max, boolean minInclusive, boolean maxInclusive)
Factory that creates aNumericRangeFilter, that filters afloatrange using the givenprecisionStep. You can have half-open ranges (which are in fact </≤ or >/≥ queries) by setting the min or max value tonull.Float.NaNwill never match a half-open range, to hitNaNuse a query withmin == max == Float.NaN. By setting inclusive to false, it will match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
-
newFloatRange
public static NumericRangeFilter<Float> newFloatRange(String field, Float min, Float max, boolean minInclusive, boolean maxInclusive)
Factory that creates aNumericRangeFilter, that queries afloatrange using the defaultprecisionStepNumericUtils.PRECISION_STEP_DEFAULT(4). You can have half-open ranges (which are in fact </≤ or >/≥ queries) by setting the min or max value tonull.Float.NaNwill never match a half-open range, to hitNaNuse a query withmin == max == Float.NaN. By setting inclusive to false, it will match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
-
includesMin
public boolean includesMin()
Returnstrueif the lower endpoint is inclusive
-
includesMax
public boolean includesMax()
Returnstrueif the upper endpoint is inclusive
-
getMin
public T getMin()
Returns the lower value of this range filter
-
getMax
public T getMax()
Returns the upper value of this range filter
-
getPrecisionStep
public int getPrecisionStep()
Returns the precision step.
-
-