org.apache.lucene.search.spans
Class SpanRangeQuery

Object
  extended by Query
      extended by SpanQuery
          extended by SpanRangeQuery
All Implemented Interfaces:
Serializable, Cloneable
Direct Known Subclasses:
BigramSpanRangeQuery

public class SpanRangeQuery
extends SpanQuery

Matches spans containing terms within a specified range.

See Also:
Serialized Form

Field Summary
private  boolean inclusive
           
private  Term lowerTerm
           
private  int termLimit
           
private static int TERMS_TO_REPORT
          Limit on the number of terms to report on an error
private  Term upperTerm
           
 
Constructor Summary
SpanRangeQuery(Term lowerTerm, Term upperTerm, boolean inclusive)
          Constructs a span query selecting all terms greater than lowerTerm but less than upperTerm.
SpanRangeQuery(Term lowerTerm, Term upperTerm, boolean inclusive, int termLimit)
          Constructs a span query selecting all terms greater than lowerTerm but less than upperTerm.
 
Method Summary
 Query combine(Query[] queries)
           
 String getField()
          Returns the field name for this query
 Term getLowerTerm()
          Returns the lower term of this range query
 Spans getSpans(IndexReader reader, Searcher searcher)
          Should never be called on this query itself, only on the result of rewrite(IndexReader).
 int getTermLimit()
          Returns the term limit, if any, for this range query
 Collection getTerms()
          Should never be called on this query itself, only on the result of rewrite(IndexReader).
 Term getUpperTerm()
          Returns the upper term of this range query
 boolean isInclusive()
          Returns true if the range query is inclusive
 Query rewrite(IndexReader reader)
          This method is actually the workhorse of the class.
protected  boolean shouldSkipTerm(Term t)
          Enables derived classes to skip certain terms in the index (e.g. stop words, bi-grams, etc.)
 String toString(String field)
           
 
Methods inherited from class SpanQuery
createWeight, getSpanRecording, setSpanRecording
 
Methods inherited from class Query
clone, extractTerms, getBoost, getSimilarity, mergeBooleanQueries, setBoost, toString, weight
 
Methods inherited from class Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

termLimit

private int termLimit

lowerTerm

private Term lowerTerm

upperTerm

private Term upperTerm

inclusive

private boolean inclusive

TERMS_TO_REPORT

private static final int TERMS_TO_REPORT
Limit on the number of terms to report on an error

See Also:
Constant Field Values
Constructor Detail

SpanRangeQuery

public SpanRangeQuery(Term lowerTerm,
                      Term upperTerm,
                      boolean inclusive)
Constructs a span 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.


SpanRangeQuery

public SpanRangeQuery(Term lowerTerm,
                      Term upperTerm,
                      boolean inclusive,
                      int termLimit)
Constructs a span 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. Applies a limit on the total number of terms matched.

Method Detail

rewrite

public Query rewrite(IndexReader reader)
              throws IOException
This method is actually the workhorse of the class. Rewrites the range query as a large span OR query on all of the matching terms.

Overrides:
rewrite in class Query
Throws:
IOException

shouldSkipTerm

protected boolean shouldSkipTerm(Term t)
Enables derived classes to skip certain terms in the index (e.g. stop words, bi-grams, etc.) Default implementation doesn't skip any terms.


combine

public Query combine(Query[] queries)
Overrides:
combine in class Query

getField

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

Specified by:
getField in class SpanQuery

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


getTermLimit

public int getTermLimit()
Returns the term limit, if any, for this range query


toString

public String toString(String field)
Specified by:
toString in class Query

getSpans

public Spans getSpans(IndexReader reader,
                      Searcher searcher)
               throws IOException
Should never be called on this query itself, only on the result of rewrite(IndexReader).

Specified by:
getSpans in class SpanQuery
Throws:
IOException

getTerms

public Collection getTerms()
Should never be called on this query itself, only on the result of rewrite(IndexReader).

Specified by:
getTerms in class SpanQuery