org.apache.jackrabbit.core.query.lucene
Class RangeQuery

java.lang.Object
  extended by org.apache.lucene.search.Query
      extended by org.apache.jackrabbit.core.query.lucene.RangeQuery
All Implemented Interfaces:
Serializable, Cloneable, Transformable, TransformConstants
Direct Known Subclasses:
LocalNameRangeQuery

public class RangeQuery
extends org.apache.lucene.search.Query
implements Transformable

Implements a variant of the lucene class RangeQuery. This class does not rewrite to basic TermQuery but will calculate the matching documents itself. That way a TooManyClauses can be avoided.

See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.apache.jackrabbit.core.query.lucene.TransformConstants
TRANSFORM_LOWER_CASE, TRANSFORM_NONE, TRANSFORM_UPPER_CASE
 
Constructor Summary
RangeQuery(org.apache.lucene.index.Term lowerTerm, org.apache.lucene.index.Term upperTerm, boolean inclusive)
          Creates a new RangeQuery.
RangeQuery(org.apache.lucene.index.Term lowerTerm, org.apache.lucene.index.Term upperTerm, boolean inclusive, int transform)
          Creates a new RangeQuery.
 
Method Summary
protected  org.apache.lucene.search.Weight createWeight(org.apache.lucene.search.Searcher searcher)
          Creates the Weight for this query.
 void extractTerms(Set terms)
          
 org.apache.lucene.search.Query rewrite(org.apache.lucene.index.IndexReader reader)
          Tries to rewrite this query into a standard lucene RangeQuery.
 void setTransformation(int transformation)
          Sets the transformation.
 String toString(String field)
          Returns a string representation of this query.
 
Methods inherited from class org.apache.lucene.search.Query
clone, combine, getBoost, getSimilarity, mergeBooleanQueries, setBoost, toString, weight
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RangeQuery

public RangeQuery(org.apache.lucene.index.Term lowerTerm,
                  org.apache.lucene.index.Term upperTerm,
                  boolean inclusive)
Creates a new RangeQuery. The lower or the upper term may be null, but not both!

Parameters:
lowerTerm - the lower term of the interval, or null
upperTerm - the upper term of the interval, or null.
inclusive - if true the interval is inclusive.

RangeQuery

public RangeQuery(org.apache.lucene.index.Term lowerTerm,
                  org.apache.lucene.index.Term upperTerm,
                  boolean inclusive,
                  int transform)
Creates a new RangeQuery. The lower or the upper term may be null, but not both!

Parameters:
lowerTerm - the lower term of the interval, or null
upperTerm - the upper term of the interval, or null.
inclusive - if true the interval is inclusive.
transform - how term enums are transformed when read from the index.
Method Detail

setTransformation

public void setTransformation(int transformation)
Sets the transformation. Must be one of the following values:

Specified by:
setTransformation in interface Transformable
Parameters:
transformation - a transform constant.

rewrite

public org.apache.lucene.search.Query rewrite(org.apache.lucene.index.IndexReader reader)
                                       throws IOException
Tries to rewrite this query into a standard lucene RangeQuery. This rewrite might fail with a TooManyClauses exception. If that happens, we use our own implementation.

Overrides:
rewrite in class org.apache.lucene.search.Query
Parameters:
reader - the index reader.
Returns:
the rewritten query or this query if rewriting is not possible.
Throws:
IOException - if an error occurs.

createWeight

protected org.apache.lucene.search.Weight createWeight(org.apache.lucene.search.Searcher searcher)
Creates the Weight for this query.

Overrides:
createWeight in class org.apache.lucene.search.Query
Parameters:
searcher - the searcher to use for the Weight.
Returns:
the Weigth for this query.

toString

public String toString(String field)
Returns a string representation of this query.

Specified by:
toString in class org.apache.lucene.search.Query
Parameters:
field - the field name for which to create a string representation.
Returns:
a string representation of this query.

extractTerms

public void extractTerms(Set terms)

Overrides:
extractTerms in class org.apache.lucene.search.Query


Copyright © 2004-2010 The Apache Software Foundation. All Rights Reserved.