org.apache.lucene.search
Class TopTermsRewrite<Q extends Query>

java.lang.Object
  extended by org.apache.lucene.search.MultiTermQuery.RewriteMethod
      extended by org.apache.lucene.search.TopTermsRewrite<Q>
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
MultiTermQuery.TopTermsBoostOnlyBooleanQueryRewrite, MultiTermQuery.TopTermsScoringBooleanQueryRewrite

public abstract class TopTermsRewrite<Q extends Query>
extends MultiTermQuery.RewriteMethod

Base rewrite method for collecting only the top terms via a priority queue.

See Also:
Serialized Form
NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
Only public to be accessible by spans package.

Nested Class Summary
protected static interface TermCollectingRewrite.TermCollector
           
 
Constructor Summary
TopTermsRewrite(int size)
          Create a TopTermsBooleanQueryRewrite for at most size terms.
 
Method Summary
protected abstract  void addClause(Q topLevel, Term term, float boost)
          Add a MultiTermQuery term to the top-level query
protected  void collectTerms(IndexReader reader, MultiTermQuery query, TermCollectingRewrite.TermCollector collector)
           
 boolean equals(Object obj)
           
protected abstract  int getMaxSize()
          return the maximum size of the priority queue (for boolean rewrites this is BooleanQuery#getMaxClauseCount).
 int getSize()
          return the maximum priority queue size
protected abstract  Q getTopLevelQuery()
          Return a suitable top-level Query for holding all expanded terms.
 int hashCode()
           
 Q rewrite(IndexReader reader, MultiTermQuery query)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TopTermsRewrite

public TopTermsRewrite(int size)
Create a TopTermsBooleanQueryRewrite for at most size terms.

NOTE: if BooleanQuery.getMaxClauseCount() is smaller than size, then it will be used instead.

Method Detail

getSize

public int getSize()
return the maximum priority queue size


getMaxSize

protected abstract int getMaxSize()
return the maximum size of the priority queue (for boolean rewrites this is BooleanQuery#getMaxClauseCount).


rewrite

public Q rewrite(IndexReader reader,
                 MultiTermQuery query)
                        throws IOException
Specified by:
rewrite in class MultiTermQuery.RewriteMethod
Throws:
IOException

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

getTopLevelQuery

protected abstract Q getTopLevelQuery()
                                             throws IOException
Return a suitable top-level Query for holding all expanded terms.

Throws:
IOException

addClause

protected abstract void addClause(Q topLevel,
                                  Term term,
                                  float boost)
                           throws IOException
Add a MultiTermQuery term to the top-level query

Throws:
IOException

collectTerms

protected final void collectTerms(IndexReader reader,
                                  MultiTermQuery query,
                                  TermCollectingRewrite.TermCollector collector)
                           throws IOException
Throws:
IOException


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