org.apache.lucene.search

Class RangeQuery

Implemented Interfaces:
Cloneable, Serializable

public class RangeQuery
extends Query

A Query that matches documents within an exclusive range. A RangeQuery is built by QueryParser for input like [010 TO 120].
Version:
$Id: RangeQuery.java 358693 2005-12-23 03:37:50Z yonik $
See Also:
Serialized Form

Constructor Summary

RangeQuery(Term lowerTerm, Term upperTerm, boolean inclusive)
Constructs a query selecting all terms greater than lowerTerm but less than upperTerm.

Method Summary

boolean
equals(Object o)
Returns true iff o is equal to this.
String
getField()
Returns the field name for this query
Term
getLowerTerm()
Returns the lower term of this range query
Term
getUpperTerm()
Returns the upper term of this range query
int
hashCode()
Returns a hash code value for this object.
boolean
isInclusive()
Returns true if the range query is inclusive
Query
rewrite(IndexReader reader)
Expert: called to re-write queries into primitive queries.
String
toString(String field)
Prints a user-readable version of this query.

Methods inherited from class org.apache.lucene.search.Query

clone, combine, createWeight, extractTerms, getBoost, getSimilarity, mergeBooleanQueries, rewrite, setBoost, toString, toString, weight

Constructor Details

RangeQuery

public RangeQuery(Term lowerTerm,
                  Term upperTerm,
                  boolean inclusive)
Constructs a query selecting all terms greater than lowerTerm but less than upperTerm. There must be at least one term and either term may be null, in which case there is no bound on that side, but if there are two terms, both terms must be for the same field.

Method Details

equals

public boolean equals(Object o)
Returns true iff o is equal to this.

getField

public String getField()
Returns the field name for this query

getLowerTerm

public Term getLowerTerm()
Returns the lower term of this range query

getUpperTerm

public Term getUpperTerm()
Returns the upper term of this range query

hashCode

public int hashCode()
Returns a hash code value for this object.

isInclusive

public boolean isInclusive()
Returns true if the range query is inclusive

rewrite

public Query rewrite(IndexReader reader)
            throws IOException
Expert: called to re-write queries into primitive queries. For example, a PrefixQuery will be rewritten into a BooleanQuery that consists of TermQuerys.
Overrides:
rewrite in interface Query

toString

public String toString(String field)
Prints a user-readable version of this query.
Overrides:
toString in interface Query

Copyright © 2000-2006 Apache Software Foundation. All Rights Reserved.