Package org.apache.lucene.search
Class TermRangeFilter
- java.lang.Object
-
- org.apache.lucene.search.Filter
-
- org.apache.lucene.search.MultiTermQueryWrapperFilter<TermRangeQuery>
-
- org.apache.lucene.search.TermRangeFilter
-
public class TermRangeFilter extends MultiTermQueryWrapperFilter<TermRangeQuery>
A Filter that restricts search results to a range of term values in a given field.This filter matches the documents looking for terms that fall into the supplied range according to
Byte.compareTo(Byte)
, It is not intended for numerical ranges; useNumericRangeFilter
instead.If you construct a large number of range filters with different ranges but on the same field,
FieldCacheRangeFilter
may have significantly better performance.- Since:
- 2.9
-
-
Constructor Summary
Constructors Constructor Description TermRangeFilter(java.lang.String fieldName, BytesRef lowerTerm, BytesRef upperTerm, boolean includeLower, boolean includeUpper)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description BytesRef
getLowerTerm()
Returns the lower value of this range filterBytesRef
getUpperTerm()
Returns the upper value of this range filterboolean
includesLower()
Returnstrue
if the lower endpoint is inclusiveboolean
includesUpper()
Returnstrue
if the upper endpoint is inclusivestatic TermRangeFilter
Less(java.lang.String fieldName, BytesRef upperTerm)
Constructs a filter for fieldfieldName
matching less than or equal toupperTerm
.static TermRangeFilter
More(java.lang.String fieldName, BytesRef lowerTerm)
Constructs a filter for fieldfieldName
matching greater than or equal tolowerTerm
.static TermRangeFilter
newStringRange(java.lang.String field, java.lang.String lowerTerm, java.lang.String upperTerm, boolean includeLower, boolean includeUpper)
Factory that creates a new TermRangeFilter using Strings for term text.-
Methods inherited from class org.apache.lucene.search.MultiTermQueryWrapperFilter
equals, getDocIdSet, getField, hashCode, toString
-
-
-
-
Constructor Detail
-
TermRangeFilter
public TermRangeFilter(java.lang.String fieldName, BytesRef lowerTerm, BytesRef upperTerm, boolean includeLower, boolean includeUpper)
- Parameters:
fieldName
- The field this range applies tolowerTerm
- The lower bound on this rangeupperTerm
- The upper bound on this rangeincludeLower
- Does this range include the lower bound?includeUpper
- Does this range include the upper bound?- Throws:
java.lang.IllegalArgumentException
- if both terms are null or if lowerTerm is null and includeLower is true (similar for upperTerm and includeUpper)
-
-
Method Detail
-
newStringRange
public static TermRangeFilter newStringRange(java.lang.String field, java.lang.String lowerTerm, java.lang.String upperTerm, boolean includeLower, boolean includeUpper)
Factory that creates a new TermRangeFilter using Strings for term text.
-
Less
public static TermRangeFilter Less(java.lang.String fieldName, BytesRef upperTerm)
Constructs a filter for fieldfieldName
matching less than or equal toupperTerm
.
-
More
public static TermRangeFilter More(java.lang.String fieldName, BytesRef lowerTerm)
Constructs a filter for fieldfieldName
matching greater than or equal tolowerTerm
.
-
getLowerTerm
public BytesRef getLowerTerm()
Returns the lower value of this range filter
-
getUpperTerm
public BytesRef getUpperTerm()
Returns the upper value of this range filter
-
includesLower
public boolean includesLower()
Returnstrue
if the lower endpoint is inclusive
-
includesUpper
public boolean includesUpper()
Returnstrue
if the upper endpoint is inclusive
-
-