public class

TermRangeFilter

extends MultiTermQueryWrapperFilter<Q extends MultiTermQuery>
java.lang.Object
   ↳ org.apache.lucene.search.Filter
     ↳ org.apache.lucene.search.MultiTermQueryWrapperFilter<Q extends org.apache.lucene.search.MultiTermQuery>
       ↳ org.apache.lucene.search.TermRangeFilter

Class Overview

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 compareTo(String), unless a Collator is provided. 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.

Summary

[Expand]
Inherited Fields
From class org.apache.lucene.search.MultiTermQueryWrapperFilter
Public Constructors
TermRangeFilter(String fieldName, String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper)
TermRangeFilter(String fieldName, String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper, Collator collator)
WARNING: Using this constructor and supplying a non-null value in the collator parameter will cause every single index Term in the Field referenced by lowerTerm and/or upperTerm to be examined.
Public Methods
static TermRangeFilter Less(String fieldName, String upperTerm)
Constructs a filter for field fieldName matching less than or equal to upperTerm.
static TermRangeFilter More(String fieldName, String lowerTerm)
Constructs a filter for field fieldName matching greater than or equal to lowerTerm.
Collator getCollator()
Returns the collator used to determine range inclusion, if any.
String getField()
Returns the field name for this filter
String getLowerTerm()
Returns the lower value of this range filter
String getUpperTerm()
Returns the upper value of this range filter
boolean includesLower()
Returns true if the lower endpoint is inclusive
boolean includesUpper()
Returns true if the upper endpoint is inclusive
[Expand]
Inherited Methods
From class org.apache.lucene.search.MultiTermQueryWrapperFilter
From class org.apache.lucene.search.Filter
From class java.lang.Object

Public Constructors

public TermRangeFilter (String fieldName, String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper)

Parameters
fieldName The field this range applies to
lowerTerm The lower bound on this range
upperTerm The upper bound on this range
includeLower 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)

public TermRangeFilter (String fieldName, String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper, Collator collator)

WARNING: Using this constructor and supplying a non-null value in the collator parameter will cause every single index Term in the Field referenced by lowerTerm and/or upperTerm to be examined. Depending on the number of index Terms in this Field, the operation could be very slow.

Parameters
lowerTerm The lower bound on this range
upperTerm The upper bound on this range
includeLower Does this range include the lower bound?
includeUpper Does this range include the upper bound?
collator The collator to use when determining range inclusion; set to null to use Unicode code point ordering instead of collation.
Throws
IllegalArgumentException if both terms are null or if lowerTerm is null and includeLower is true (similar for upperTerm and includeUpper)

Public Methods

public static TermRangeFilter Less (String fieldName, String upperTerm)

Constructs a filter for field fieldName matching less than or equal to upperTerm.

public static TermRangeFilter More (String fieldName, String lowerTerm)

Constructs a filter for field fieldName matching greater than or equal to lowerTerm.

public Collator getCollator ()

Returns the collator used to determine range inclusion, if any.

public String getField ()

Returns the field name for this filter

public String getLowerTerm ()

Returns the lower value of this range filter

public String getUpperTerm ()

Returns the upper value of this range filter

public boolean includesLower ()

Returns true if the lower endpoint is inclusive

public boolean includesUpper ()

Returns true if the upper endpoint is inclusive