Class FieldCacheRangeFilter
A range filter built on top of a cached single term field (in IFieldCache).
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 Int32Field, SingleField, Int64Field or DoubleField. But it has the problem that it only works with exact one value/document (see below).
As with all IFieldCache 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 IFieldCache, 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 IFieldCache.
Inheritance
Inherited Members
Namespace: Lucene.Net.Search
Assembly: Lucene.Net.dll
Syntax
public static class FieldCacheRangeFilter
Methods
| Improve this Doc View SourceNewByteRange(String, FieldCache.IByteParser, Nullable<SByte>, Nullable<SByte>, Boolean, Boolean)
Creates a numeric range filter using GetBytes(AtomicReader, String, FieldCache.IByteParser, Boolean). This works with all
System.Byte fields containing exactly one numeric term in the field. The range can be half-open by setting one
of the values to null
.
Declaration
[Obsolete]
[CLSCompliant(false)]
public static FieldCacheRangeFilter<sbyte?> NewByteRange(string field, FieldCache.IByteParser parser, sbyte? lowerVal, sbyte? upperVal, bool includeLower, bool includeUpper)
Parameters
Type | Name | Description |
---|---|---|
System.String | field | |
FieldCache.IByteParser | parser | |
System.Nullable<System.SByte> | lowerVal | |
System.Nullable<System.SByte> | upperVal | |
System.Boolean | includeLower | |
System.Boolean | includeUpper |
Returns
Type | Description |
---|---|
FieldCacheRangeFilter<System.Nullable<System.SByte>> |
NewByteRange(String, Nullable<SByte>, Nullable<SByte>, Boolean, Boolean)
Creates a numeric range filter using GetBytes(AtomicReader, String, Boolean). This works with all
System.Byte fields containing exactly one numeric term in the field. The range can be half-open by setting one
of the values to null
.
Declaration
[Obsolete]
[CLSCompliant(false)]
public static FieldCacheRangeFilter<sbyte?> NewByteRange(string field, sbyte? lowerVal, sbyte? upperVal, bool includeLower, bool includeUpper)
Parameters
Type | Name | Description |
---|---|---|
System.String | field | |
System.Nullable<System.SByte> | lowerVal | |
System.Nullable<System.SByte> | upperVal | |
System.Boolean | includeLower | |
System.Boolean | includeUpper |
Returns
Type | Description |
---|---|
FieldCacheRangeFilter<System.Nullable<System.SByte>> |
NewBytesRefRange(String, BytesRef, BytesRef, Boolean, Boolean)
Creates a BytesRef range filter using GetTermsIndex(AtomicReader, String, Single). 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
.
Declaration
public static FieldCacheRangeFilter<BytesRef> NewBytesRefRange(string field, BytesRef lowerVal, BytesRef upperVal, bool includeLower, bool includeUpper)
Parameters
Type | Name | Description |
---|---|---|
System.String | field | |
BytesRef | lowerVal | |
BytesRef | upperVal | |
System.Boolean | includeLower | |
System.Boolean | includeUpper |
Returns
Type | Description |
---|---|
FieldCacheRangeFilter<BytesRef> |
NewDoubleRange(String, FieldCache.IDoubleParser, Nullable<Double>, Nullable<Double>, Boolean, Boolean)
Creates a numeric range filter using GetDoubles(AtomicReader, String, FieldCache.IDoubleParser, Boolean). This works with all
System.Double fields containing exactly one numeric term in the field. The range can be half-open by setting one
of the values to null
.
Declaration
public static FieldCacheRangeFilter<double?> NewDoubleRange(string field, FieldCache.IDoubleParser parser, double? lowerVal, double? upperVal, bool includeLower, bool includeUpper)
Parameters
Type | Name | Description |
---|---|---|
System.String | field | |
FieldCache.IDoubleParser | parser | |
System.Nullable<System.Double> | lowerVal | |
System.Nullable<System.Double> | upperVal | |
System.Boolean | includeLower | |
System.Boolean | includeUpper |
Returns
Type | Description |
---|---|
FieldCacheRangeFilter<System.Nullable<System.Double>> |
NewDoubleRange(String, Nullable<Double>, Nullable<Double>, Boolean, Boolean)
Creates a numeric range filter using GetDoubles(AtomicReader, String, Boolean). This works with all
System.Double fields containing exactly one numeric term in the field. The range can be half-open by setting one
of the values to null
.
Declaration
public static FieldCacheRangeFilter<double?> NewDoubleRange(string field, double? lowerVal, double? upperVal, bool includeLower, bool includeUpper)
Parameters
Type | Name | Description |
---|---|---|
System.String | field | |
System.Nullable<System.Double> | lowerVal | |
System.Nullable<System.Double> | upperVal | |
System.Boolean | includeLower | |
System.Boolean | includeUpper |
Returns
Type | Description |
---|---|
FieldCacheRangeFilter<System.Nullable<System.Double>> |
NewInt16Range(String, FieldCache.IInt16Parser, Nullable<Int16>, Nullable<Int16>, Boolean, Boolean)
Creates a numeric range filter using GetInt16s(AtomicReader, String, FieldCache.IInt16Parser, Boolean). This works with all
System.Int16 fields containing exactly one numeric term in the field. The range can be half-open by setting one
of the values to null
.
NOTE: this was newShortRange() in Lucene
Declaration
[Obsolete]
public static FieldCacheRangeFilter<short?> NewInt16Range(string field, FieldCache.IInt16Parser parser, short? lowerVal, short? upperVal, bool includeLower, bool includeUpper)
Parameters
Type | Name | Description |
---|---|---|
System.String | field | |
FieldCache.IInt16Parser | parser | |
System.Nullable<System.Int16> | lowerVal | |
System.Nullable<System.Int16> | upperVal | |
System.Boolean | includeLower | |
System.Boolean | includeUpper |
Returns
Type | Description |
---|---|
FieldCacheRangeFilter<System.Nullable<System.Int16>> |
NewInt16Range(String, Nullable<Int16>, Nullable<Int16>, Boolean, Boolean)
Creates a numeric range filter using GetInt16s(AtomicReader, String, Boolean). This works with all
System.Int16 fields containing exactly one numeric term in the field. The range can be half-open by setting one
of the values to null
.
NOTE: this was newShortRange() in Lucene
Declaration
[Obsolete]
public static FieldCacheRangeFilter<short?> NewInt16Range(string field, short? lowerVal, short? upperVal, bool includeLower, bool includeUpper)
Parameters
Type | Name | Description |
---|---|---|
System.String | field | |
System.Nullable<System.Int16> | lowerVal | |
System.Nullable<System.Int16> | upperVal | |
System.Boolean | includeLower | |
System.Boolean | includeUpper |
Returns
Type | Description |
---|---|
FieldCacheRangeFilter<System.Nullable<System.Int16>> |
NewInt32Range(String, FieldCache.IInt32Parser, Nullable<Int32>, Nullable<Int32>, Boolean, Boolean)
Creates a numeric range filter using GetInt32s(AtomicReader, String, FieldCache.IInt32Parser, Boolean). This works with all
System.Int32 fields containing exactly one numeric term in the field. The range can be half-open by setting one
of the values to null
.
NOTE: this was newIntRange() in Lucene
Declaration
public static FieldCacheRangeFilter<int?> NewInt32Range(string field, FieldCache.IInt32Parser parser, int? lowerVal, int? upperVal, bool includeLower, bool includeUpper)
Parameters
Type | Name | Description |
---|---|---|
System.String | field | |
FieldCache.IInt32Parser | parser | |
System.Nullable<System.Int32> | lowerVal | |
System.Nullable<System.Int32> | upperVal | |
System.Boolean | includeLower | |
System.Boolean | includeUpper |
Returns
Type | Description |
---|---|
FieldCacheRangeFilter<System.Nullable<System.Int32>> |
NewInt32Range(String, Nullable<Int32>, Nullable<Int32>, Boolean, Boolean)
Creates a numeric range filter using GetInt32s(AtomicReader, String, Boolean). This works with all
System.Int32 fields containing exactly one numeric term in the field. The range can be half-open by setting one
of the values to null
.
NOTE: this was newIntRange() in Lucene
Declaration
public static FieldCacheRangeFilter<int?> NewInt32Range(string field, int? lowerVal, int? upperVal, bool includeLower, bool includeUpper)
Parameters
Type | Name | Description |
---|---|---|
System.String | field | |
System.Nullable<System.Int32> | lowerVal | |
System.Nullable<System.Int32> | upperVal | |
System.Boolean | includeLower | |
System.Boolean | includeUpper |
Returns
Type | Description |
---|---|
FieldCacheRangeFilter<System.Nullable<System.Int32>> |
NewInt64Range(String, FieldCache.IInt64Parser, Nullable<Int64>, Nullable<Int64>, Boolean, Boolean)
Creates a numeric range filter using GetInt64s(AtomicReader, String, FieldCache.IInt64Parser, Boolean). This works with all
System.Int64 fields containing exactly one numeric term in the field. The range can be half-open by setting one
of the values to null
.
NOTE: this was newLongRange() in Lucene
Declaration
public static FieldCacheRangeFilter<long?> NewInt64Range(string field, FieldCache.IInt64Parser parser, long? lowerVal, long? upperVal, bool includeLower, bool includeUpper)
Parameters
Type | Name | Description |
---|---|---|
System.String | field | |
FieldCache.IInt64Parser | parser | |
System.Nullable<System.Int64> | lowerVal | |
System.Nullable<System.Int64> | upperVal | |
System.Boolean | includeLower | |
System.Boolean | includeUpper |
Returns
Type | Description |
---|---|
FieldCacheRangeFilter<System.Nullable<System.Int64>> |
NewInt64Range(String, Nullable<Int64>, Nullable<Int64>, Boolean, Boolean)
Creates a numeric range filter using GetInt64s(AtomicReader, String, Boolean). This works with all
System.Int64 fields containing exactly one numeric term in the field. The range can be half-open by setting one
of the values to null
.
Declaration
public static FieldCacheRangeFilter<long?> NewInt64Range(string field, long? lowerVal, long? upperVal, bool includeLower, bool includeUpper)
Parameters
Type | Name | Description |
---|---|---|
System.String | field | |
System.Nullable<System.Int64> | lowerVal | |
System.Nullable<System.Int64> | upperVal | |
System.Boolean | includeLower | |
System.Boolean | includeUpper |
Returns
Type | Description |
---|---|
FieldCacheRangeFilter<System.Nullable<System.Int64>> |
NewSingleRange(String, FieldCache.ISingleParser, Nullable<Single>, Nullable<Single>, Boolean, Boolean)
Creates a numeric range filter using GetSingles(AtomicReader, String, FieldCache.ISingleParser, Boolean). This works with all
System.Single fields containing exactly one numeric term in the field. The range can be half-open by setting one
of the values to null
.
NOTE: this was newFloatRange() in Lucene
Declaration
public static FieldCacheRangeFilter<float?> NewSingleRange(string field, FieldCache.ISingleParser parser, float? lowerVal, float? upperVal, bool includeLower, bool includeUpper)
Parameters
Type | Name | Description |
---|---|---|
System.String | field | |
FieldCache.ISingleParser | parser | |
System.Nullable<System.Single> | lowerVal | |
System.Nullable<System.Single> | upperVal | |
System.Boolean | includeLower | |
System.Boolean | includeUpper |
Returns
Type | Description |
---|---|
FieldCacheRangeFilter<System.Nullable<System.Single>> |
NewSingleRange(String, Nullable<Single>, Nullable<Single>, Boolean, Boolean)
Creates a numeric range filter using GetSingles(AtomicReader, String, Boolean). This works with all
System.Single fields containing exactly one numeric term in the field. The range can be half-open by setting one
of the values to null
.
NOTE: this was newFloatRange() in Lucene
Declaration
public static FieldCacheRangeFilter<float?> NewSingleRange(string field, float? lowerVal, float? upperVal, bool includeLower, bool includeUpper)
Parameters
Type | Name | Description |
---|---|---|
System.String | field | |
System.Nullable<System.Single> | lowerVal | |
System.Nullable<System.Single> | upperVal | |
System.Boolean | includeLower | |
System.Boolean | includeUpper |
Returns
Type | Description |
---|---|
FieldCacheRangeFilter<System.Nullable<System.Single>> |
NewStringRange(String, String, String, Boolean, Boolean)
Creates a string range filter using GetTermsIndex(AtomicReader, String, Single). 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
.
Declaration
public static FieldCacheRangeFilter<string> NewStringRange(string field, string lowerVal, string upperVal, bool includeLower, bool includeUpper)
Parameters
Type | Name | Description |
---|---|---|
System.String | field | |
System.String | lowerVal | |
System.String | upperVal | |
System.Boolean | includeLower | |
System.Boolean | includeUpper |
Returns
Type | Description |
---|---|
FieldCacheRangeFilter<System.String> |