Class TermRangeQuery
A Query that matches documents within an range of terms.
This query matches the documents looking for terms that fall into the supplied range according to CompareTo(byte). It is not intended for numerical ranges; use NumericRangeQuery instead. This query uses the CONSTANT_SCORE_AUTO_REWRITE_DEFAULT rewrite method. @since 2.9Inherited Members
Namespace: Lucene.Net.Search
Assembly: Lucene.Net.dll
Syntax
public class TermRangeQuery : MultiTermQuery
Constructors
TermRangeQuery(string, BytesRef, BytesRef, bool, bool)
Constructs a query selecting all terms greater/equal than lowerTerm
but less/equal than upperTerm
.
null
, it is said
to be "open". Either or both endpoints may be open. Open endpoints may not
be exclusive (you can't select all but the first or last term without
explicitly specifying the term to exclude.)
Declaration
public TermRangeQuery(string field, BytesRef lowerTerm, BytesRef upperTerm, bool includeLower, bool includeUpper)
Parameters
Type | Name | Description |
---|---|---|
string | field | The field that holds both lower and upper terms. |
BytesRef | lowerTerm | The term text at the lower end of the range. |
BytesRef | upperTerm | The term text at the upper end of the range. |
bool | includeLower | If true, the |
bool | includeUpper | If true, the |
Properties
IncludesLower
Returns true
if the lower endpoint is inclusive
Declaration
public virtual bool IncludesLower { get; }
Property Value
Type | Description |
---|---|
bool |
IncludesUpper
Returns true
if the upper endpoint is inclusive
Declaration
public virtual bool IncludesUpper { get; }
Property Value
Type | Description |
---|---|
bool |
LowerTerm
Returns the lower value of this range query
Declaration
public virtual BytesRef LowerTerm { get; }
Property Value
Type | Description |
---|---|
BytesRef |
UpperTerm
Returns the upper value of this range query
Declaration
public virtual BytesRef UpperTerm { get; }
Property Value
Type | Description |
---|---|
BytesRef |
Methods
Equals(object)
Determines whether the specified object is equal to the current object.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj | The object to compare with the current object. |
Returns
Type | Description |
---|---|
bool | true if the specified object is equal to the current object; otherwise, false. |
Overrides
GetHashCode()
Serves as the default hash function.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int | A hash code for the current object. |
Overrides
GetTermsEnum(Terms, AttributeSource)
Construct the enumeration to be used, expanding the pattern term. this method should only be called if the field exists (ie, implementations can assume the field does exist). this method should not return null (should instead return EMPTY if no terms match). The TermsEnum must already be positioned to the first matching term. The given AttributeSource is passed by the MultiTermQuery.RewriteMethod to provide attributes, the rewrite method uses to inform about e.g. maximum competitive boosts. this is currently only used by TopTermsRewrite<Q>.
Declaration
protected override TermsEnum GetTermsEnum(Terms terms, AttributeSource atts)
Parameters
Type | Name | Description |
---|---|---|
Terms | terms | |
AttributeSource | atts |
Returns
Type | Description |
---|---|
TermsEnum |
Overrides
NewStringRange(string, string, string, bool, bool)
Factory that creates a new TermRangeQuery using strings for term text.
Declaration
public static TermRangeQuery NewStringRange(string field, string lowerTerm, string upperTerm, bool includeLower, bool includeUpper)
Parameters
Type | Name | Description |
---|---|---|
string | field | |
string | lowerTerm | |
string | upperTerm | |
bool | includeLower | |
bool | includeUpper |
Returns
Type | Description |
---|---|
TermRangeQuery |
ToString(string)
Prints a user-readable version of this query.
Declaration
public override string ToString(string field)
Parameters
Type | Name | Description |
---|---|---|
string | field |
Returns
Type | Description |
---|---|
string |