org.apache.lucene.search
Class MultiTermQuery.TopTermsScoringBooleanQueryRewrite

java.lang.Object
  extended by org.apache.lucene.search.MultiTermQuery.RewriteMethod
      extended by org.apache.lucene.search.TopTermsRewrite<BooleanQuery>
          extended by org.apache.lucene.search.MultiTermQuery.TopTermsScoringBooleanQueryRewrite
All Implemented Interfaces:
Serializable
Enclosing class:
MultiTermQuery

public static final class MultiTermQuery.TopTermsScoringBooleanQueryRewrite
extends TopTermsRewrite<BooleanQuery>

A rewrite method that first translates each term into BooleanClause.Occur.SHOULD clause in a BooleanQuery, and keeps the scores as computed by the query.

This rewrite method only uses the top scoring terms so it will not overflow the boolean max clause count. It is the default rewrite method for FuzzyQuery.

See Also:
MultiTermQuery.setRewriteMethod(org.apache.lucene.search.MultiTermQuery.RewriteMethod), Serialized Form

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

Constructor Detail

MultiTermQuery.TopTermsScoringBooleanQueryRewrite

public MultiTermQuery.TopTermsScoringBooleanQueryRewrite(int size)
Create a TopTermsScoringBooleanQueryRewrite for at most size terms.

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

Method Detail

getMaxSize

protected int getMaxSize()
Description copied from class: TopTermsRewrite
return the maximum size of the priority queue (for boolean rewrites this is BooleanQuery#getMaxClauseCount).

Specified by:
getMaxSize in class TopTermsRewrite<BooleanQuery>

getTopLevelQuery

protected BooleanQuery getTopLevelQuery()
Return a suitable top-level Query for holding all expanded terms.


addClause

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


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.