## org.apache.lucene.search
Class RangeQuery

    java.lang.Object
      org.apache.lucene.search.Query
          org.apache.lucene.search.RangeQuery

All Implemented Interfaces:
  Serializable, Cloneable

    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]` but only if the QueryParser has the useOldRangeQuery property set to true. The QueryParser default behaviour is to use the newer ConstantScoreRangeQuery class. This is generally preferable because:

- It is faster than RangeQuery
- Unlike RangeQuery, it does not cause a BooleanQuery.TooManyClauses exception if the range of values is large
- Unlike RangeQuery it does not influence scoring based on the scarcity of individual terms that may match

Version:
  $Id: RangeQuery.java 520891 2007-03-21 13:58:47Z yonik $
See Also:
  `ConstantScoreRangeQuery`, 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, setBoost, toString, weight`

Methods inherited from class java.lang.Object
`finalize, getClass, notify, notifyAll, wait, wait, wait`

Constructor Detail

### 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 Detail

### rewrite

    public Query rewrite(IndexReader reader)
                  throws IOException

  Description copied from class: `Query`
  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 class `Query`
  Throws:
    `IOException`

### 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

### isInclusive

    public boolean isInclusive()

  Returns `true` if the range query is inclusive

### toString

    public String toString(String field)

  Prints a user-readable version of this query.

  Specified by:
    `toString` in class `Query`

### equals

    public boolean equals(Object o)

  Returns true iff `o` is equal to this.

  Overrides:
    `equals` in class `Object`

### hashCode

    public int hashCode()

  Returns a hash code value for this object.

  Overrides:
    `hashCode` in class `Object`

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