java.lang.Object | ||
↳ | org.apache.lucene.search.Filter | |
↳ | org.apache.lucene.search.FieldCacheRangeFilter<T> |
A range filter built on top of a cached single term field (in FieldCache
).
FieldCacheRangeFilter
builds a single cache for the field the first time it is used.
Each subsequent FieldCacheRangeFilter
on the same field then reuses this cache,
even if the range itself changes.
This means that FieldCacheRangeFilter
is much faster (sometimes more than 100x as fast)
as building a TermRangeFilter
, if using a newStringRange(String, String, String, boolean, boolean)
.
However, if the range never changes it is slower (around 2x as slow) than building
a CachingWrapperFilter on top of a single TermRangeFilter
.
For numeric data types, this filter may be significantly faster than NumericRangeFilter
.
Furthermore, it does not need the numeric values encoded by NumericField
. But
it has the problem that it only works with exact one value/document (see below).
As with all FieldCache
based functionality, FieldCacheRangeFilter
is only valid for
fields which exact one term for each document (except for newStringRange(String, String, String, boolean, boolean)
where 0 terms are also allowed). Due to a restriction of FieldCache
, for numeric ranges
all terms that do not have a numeric value, 0 is assumed.
Thus it works on dates, prices and other single value fields but will not work on
regular text fields. It is preferable to use a NOT_ANALYZED
field to ensure that
there is only a single term.
This class does not have an constructor, use one of the static factory methods available,
that create a correct instance for different data types supported by FieldCache
.
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
This method is implemented for each data type
| |||||||||||
Returns the field name for this filter
| |||||||||||
Returns the lower value of this range filter
| |||||||||||
Returns the current numeric parser (
null for T is String } | |||||||||||
Returns the upper value of this range filter
| |||||||||||
Returns
true if the lower endpoint is inclusive | |||||||||||
Returns
true if the upper endpoint is inclusive | |||||||||||
Creates a numeric range filter using
getBytes(IndexReader, String, FieldCache.ByteParser) . | |||||||||||
Creates a numeric range filter using
getBytes(IndexReader, String) . | |||||||||||
Creates a numeric range filter using
getDoubles(IndexReader, String, FieldCache.DoubleParser) . | |||||||||||
Creates a numeric range filter using
getDoubles(IndexReader, String) . | |||||||||||
Creates a numeric range filter using
getFloats(IndexReader, String) . | |||||||||||
Creates a numeric range filter using
getFloats(IndexReader, String, FieldCache.FloatParser) . | |||||||||||
Creates a numeric range filter using
getInts(IndexReader, String) . | |||||||||||
Creates a numeric range filter using
getInts(IndexReader, String, FieldCache.IntParser) . | |||||||||||
Creates a numeric range filter using
getLongs(IndexReader, String) . | |||||||||||
Creates a numeric range filter using
getLongs(IndexReader, String, FieldCache.LongParser) . | |||||||||||
Creates a numeric range filter using
getShorts(IndexReader, String) . | |||||||||||
Creates a numeric range filter using
getShorts(IndexReader, String, FieldCache.ShortParser) . | |||||||||||
Creates a string range filter using
getStringIndex(IndexReader, String) . | |||||||||||
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.apache.lucene.search.Filter
| |||||||||||
From class
java.lang.Object
|
This method is implemented for each data type
reader | a IndexReader instance opened on the index currently
searched on. Note, it is likely that the provided reader does not
represent the whole underlying index i.e. if the index has more than
one segment the given reader only represents a single segment. |
---|
IOException |
---|
Returns the lower value of this range filter
Returns the upper value of this range filter
Returns true
if the lower endpoint is inclusive
Returns true
if the upper endpoint is inclusive
Creates a numeric range filter using getBytes(IndexReader, String, FieldCache.ByteParser)
. This works with all
byte fields containing exactly one numeric term in the field. The range can be half-open by setting one
of the values to null
.
Creates a numeric range filter using getBytes(IndexReader, String)
. This works with all
byte fields containing exactly one numeric term in the field. The range can be half-open by setting one
of the values to null
.
Creates a numeric range filter using getDoubles(IndexReader, String, FieldCache.DoubleParser)
. This works with all
double fields containing exactly one numeric term in the field. The range can be half-open by setting one
of the values to null
.
Creates a numeric range filter using getDoubles(IndexReader, String)
. This works with all
double fields containing exactly one numeric term in the field. The range can be half-open by setting one
of the values to null
.
Creates a numeric range filter using getFloats(IndexReader, String)
. This works with all
float fields containing exactly one numeric term in the field. The range can be half-open by setting one
of the values to null
.
Creates a numeric range filter using getFloats(IndexReader, String, FieldCache.FloatParser)
. This works with all
float fields containing exactly one numeric term in the field. The range can be half-open by setting one
of the values to null
.
Creates a numeric range filter using getInts(IndexReader, String)
. This works with all
int fields containing exactly one numeric term in the field. The range can be half-open by setting one
of the values to null
.
Creates a numeric range filter using getInts(IndexReader, String, FieldCache.IntParser)
. This works with all
int fields containing exactly one numeric term in the field. The range can be half-open by setting one
of the values to null
.
Creates a numeric range filter using getLongs(IndexReader, String)
. This works with all
long fields containing exactly one numeric term in the field. The range can be half-open by setting one
of the values to null
.
Creates a numeric range filter using getLongs(IndexReader, String, FieldCache.LongParser)
. This works with all
long fields containing exactly one numeric term in the field. The range can be half-open by setting one
of the values to null
.
Creates a numeric range filter using getShorts(IndexReader, String)
. This works with all
short fields containing exactly one numeric term in the field. The range can be half-open by setting one
of the values to null
.
Creates a numeric range filter using getShorts(IndexReader, String, FieldCache.ShortParser)
. This works with all
short fields containing exactly one numeric term in the field. The range can be half-open by setting one
of the values to null
.
Creates a string range filter using getStringIndex(IndexReader, String)
. This works with all
fields containing zero or one term in the field. The range can be half-open by setting one
of the values to null
.