RangeQuery (Lucene 2.4.1 API)
Keywords: org.apache.lucene.search.RangeQuery class

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## 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 696056 2008-09-16 21:03:21Z gsingers $
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`.
`RangeQuery(Term lowerTerm, Term upperTerm, boolean inclusive, Collator collator)` 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.
`Collator` | `getCollator()` Returns the collator used to determine range inclusion, if any.
`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.

  Parameters:
    `lowerTerm` - The Term at the lower end of the range
    `upperTerm` - The Term at the upper end of the range
    `inclusive` - If true, both `lowerTerm` and `upperTerm` will themselves be included in the range.

### RangeQuery

    public RangeQuery(Term lowerTerm,
                      Term upperTerm,
                      boolean inclusive,
                      Collator collator)

  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.

  If `collator` is not null, it will be used to decide whether index terms are within the given range, rather than using the Unicode code point order in which index terms are stored.

  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 Term at the lower end of the range
    `upperTerm` - The Term at the upper end of the range
    `inclusive` - If true, both `lowerTerm` and `upperTerm` will themselves be included in the range.
    `collator` - The collator to use to collate index Terms, to determine their membership in the range bounded by `lowerTerm` and `upperTerm`.

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

### getCollator

    public Collator getCollator()

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

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

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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