Package org.apache.lucene.search
Class NumericRangeFilter<T extends java.lang.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 java.lang.Number> extends MultiTermQueryWrapperFilter<NumericRangeQuery<T>>
AFilter
that only accepts numeric values within a specified range. To use this, you must first index the numeric values usingIntField
,FloatField
,LongField
orDoubleField
(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. SeeNumericRangeQuery
for 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 T
getMax()
Returns the upper value of this range filterT
getMin()
Returns the lower value of this range filterint
getPrecisionStep()
Returns the precision step.boolean
includesMax()
Returnstrue
if the upper endpoint is inclusiveboolean
includesMin()
Returnstrue
if the lower endpoint is inclusivestatic NumericRangeFilter<java.lang.Double>
newDoubleRange(java.lang.String field, int precisionStep, java.lang.Double min, java.lang.Double max, boolean minInclusive, boolean maxInclusive)
Factory that creates aNumericRangeFilter
, that filters adouble
range using the givenprecisionStep
.static NumericRangeFilter<java.lang.Double>
newDoubleRange(java.lang.String field, java.lang.Double min, java.lang.Double max, boolean minInclusive, boolean maxInclusive)
Factory that creates aNumericRangeFilter
, that queries adouble
range using the defaultprecisionStep
NumericUtils.PRECISION_STEP_DEFAULT
(4).static NumericRangeFilter<java.lang.Float>
newFloatRange(java.lang.String field, int precisionStep, java.lang.Float min, java.lang.Float max, boolean minInclusive, boolean maxInclusive)
Factory that creates aNumericRangeFilter
, that filters afloat
range using the givenprecisionStep
.static NumericRangeFilter<java.lang.Float>
newFloatRange(java.lang.String field, java.lang.Float min, java.lang.Float max, boolean minInclusive, boolean maxInclusive)
Factory that creates aNumericRangeFilter
, that queries afloat
range using the defaultprecisionStep
NumericUtils.PRECISION_STEP_DEFAULT
(4).static NumericRangeFilter<java.lang.Integer>
newIntRange(java.lang.String field, int precisionStep, java.lang.Integer min, java.lang.Integer max, boolean minInclusive, boolean maxInclusive)
static NumericRangeFilter<java.lang.Integer>
newIntRange(java.lang.String field, java.lang.Integer min, java.lang.Integer max, boolean minInclusive, boolean maxInclusive)
Factory that creates aNumericRangeFilter
, that queries aint
range using the defaultprecisionStep
NumericUtils.PRECISION_STEP_DEFAULT
(4).static NumericRangeFilter<java.lang.Long>
newLongRange(java.lang.String field, int precisionStep, java.lang.Long min, java.lang.Long max, boolean minInclusive, boolean maxInclusive)
static NumericRangeFilter<java.lang.Long>
newLongRange(java.lang.String field, java.lang.Long min, java.lang.Long max, boolean minInclusive, boolean maxInclusive)
Factory that creates aNumericRangeFilter
, that queries along
range using the defaultprecisionStep
NumericUtils.PRECISION_STEP_DEFAULT
(4).-
Methods inherited from class org.apache.lucene.search.MultiTermQueryWrapperFilter
equals, getDocIdSet, getField, hashCode, toString
-
-
-
-
Method Detail
-
newLongRange
public static NumericRangeFilter<java.lang.Long> newLongRange(java.lang.String field, int precisionStep, java.lang.Long min, java.lang.Long max, boolean minInclusive, boolean maxInclusive)
Factory that creates aNumericRangeFilter
, that filters along
range 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<java.lang.Long> newLongRange(java.lang.String field, java.lang.Long min, java.lang.Long max, boolean minInclusive, boolean maxInclusive)
Factory that creates aNumericRangeFilter
, that queries along
range using the defaultprecisionStep
NumericUtils.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<java.lang.Integer> newIntRange(java.lang.String field, int precisionStep, java.lang.Integer min, java.lang.Integer max, boolean minInclusive, boolean maxInclusive)
Factory that creates aNumericRangeFilter
, that filters aint
range 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<java.lang.Integer> newIntRange(java.lang.String field, java.lang.Integer min, java.lang.Integer max, boolean minInclusive, boolean maxInclusive)
Factory that creates aNumericRangeFilter
, that queries aint
range using the defaultprecisionStep
NumericUtils.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<java.lang.Double> newDoubleRange(java.lang.String field, int precisionStep, java.lang.Double min, java.lang.Double max, boolean minInclusive, boolean maxInclusive)
Factory that creates aNumericRangeFilter
, that filters adouble
range using the givenprecisionStep
. You can have half-open ranges (which are in fact </≤ or >/≥ queries) by setting the min or max value tonull
.Double.NaN
will never match a half-open range, to hitNaN
use 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<java.lang.Double> newDoubleRange(java.lang.String field, java.lang.Double min, java.lang.Double max, boolean minInclusive, boolean maxInclusive)
Factory that creates aNumericRangeFilter
, that queries adouble
range using the defaultprecisionStep
NumericUtils.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.NaN
will never match a half-open range, to hitNaN
use 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<java.lang.Float> newFloatRange(java.lang.String field, int precisionStep, java.lang.Float min, java.lang.Float max, boolean minInclusive, boolean maxInclusive)
Factory that creates aNumericRangeFilter
, that filters afloat
range using the givenprecisionStep
. You can have half-open ranges (which are in fact </≤ or >/≥ queries) by setting the min or max value tonull
.Float.NaN
will never match a half-open range, to hitNaN
use 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<java.lang.Float> newFloatRange(java.lang.String field, java.lang.Float min, java.lang.Float max, boolean minInclusive, boolean maxInclusive)
Factory that creates aNumericRangeFilter
, that queries afloat
range using the defaultprecisionStep
NumericUtils.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.NaN
will never match a half-open range, to hitNaN
use 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()
Returnstrue
if the lower endpoint is inclusive
-
includesMax
public boolean includesMax()
Returnstrue
if 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.
-
-