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>>
A
Filter that only accepts numeric values within
a specified range. To use this, you must first index the
numeric values using IntField, FloatField, LongField or DoubleField (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.
See NumericRangeQuery for details on how Lucene
indexes and searches numeric valued fields.- Since:
- 2.9
-
Method Summary
Modifier and TypeMethodDescriptiongetMax()Returns the upper value of this range filtergetMin()Returns the lower value of this range filterintReturns the precision step.booleanReturnstrueif the upper endpoint is inclusivebooleanReturnstrueif 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 Details
-
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
Returns the lower value of this range filter -
getMax
Returns the upper value of this range filter -
getPrecisionStep
public int getPrecisionStep()Returns the precision step.
-