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
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; use NumericRangeFilter 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
ConstructorsConstructorDescriptionTermRangeFilter(String fieldName, BytesRef lowerTerm, BytesRef upperTerm, boolean includeLower, boolean includeUpper) -
Method Summary
Modifier and TypeMethodDescriptionReturns the lower value of this range filterReturns the upper value of this range filterbooleanReturnstrueif the lower endpoint is inclusivebooleanReturnstrueif the upper endpoint is inclusivestatic TermRangeFilterConstructs a filter for fieldfieldNamematching less than or equal toupperTerm.static TermRangeFilterConstructs a filter for fieldfieldNamematching greater than or equal tolowerTerm.static TermRangeFilternewStringRange(String field, String lowerTerm, 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 Details
-
TermRangeFilter
public TermRangeFilter(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:
IllegalArgumentException- if both terms are null or if lowerTerm is null and includeLower is true (similar for upperTerm and includeUpper)
-
-
Method Details
-
newStringRange
public static TermRangeFilter newStringRange(String field, String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) Factory that creates a new TermRangeFilter using Strings for term text. -
Less
Constructs a filter for fieldfieldNamematching less than or equal toupperTerm. -
More
Constructs a filter for fieldfieldNamematching greater than or equal tolowerTerm. -
getLowerTerm
Returns the lower value of this range filter -
getUpperTerm
Returns the upper value of this range filter -
includesLower
public boolean includesLower()Returnstrueif the lower endpoint is inclusive -
includesUpper
public boolean includesUpper()Returnstrueif the upper endpoint is inclusive
-