org.apache.lucene.search
Class MultiTermQuery.ConstantScoreAutoRewrite

java.lang.Object
  extended by org.apache.lucene.search.MultiTermQuery.RewriteMethod
      extended by org.apache.lucene.search.MultiTermQuery.ConstantScoreAutoRewrite
All Implemented Interfaces:
Serializable
Enclosing class:
MultiTermQuery

public static class MultiTermQuery.ConstantScoreAutoRewrite
extends MultiTermQuery.RewriteMethod

A rewrite method that tries to pick the best constant-score rewrite method based on term and document counts from the query. If both the number of terms and documents is small enough, then MultiTermQuery.CONSTANT_SCORE_BOOLEAN_QUERY_REWRITE is used. Otherwise, MultiTermQuery.CONSTANT_SCORE_FILTER_REWRITE is used.

See Also:
Serialized Form

Nested Class Summary
protected static interface TermCollectingRewrite.TermCollector
           
 
Field Summary
static double DEFAULT_DOC_COUNT_PERCENT
           
static int DEFAULT_TERM_COUNT_CUTOFF
           
 
Constructor Summary
MultiTermQuery.ConstantScoreAutoRewrite()
           
 
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)
           
 boolean equals(Object obj)
           
 double getDocCountPercent()
           
 int getTermCountCutoff()
           
protected  BooleanQuery getTopLevelQuery()
          Return a suitable top-level Query for holding all expanded terms.
 int hashCode()
           
 Query rewrite(IndexReader reader, MultiTermQuery query)
           
 void setDocCountPercent(double percent)
          If the number of documents to be visited in the postings exceeds this specified percentage of the maxDoc() for the index, then MultiTermQuery.CONSTANT_SCORE_FILTER_REWRITE is used.
 void setTermCountCutoff(int count)
          If the number of terms in this query is equal to or larger than this setting then MultiTermQuery.CONSTANT_SCORE_FILTER_REWRITE is used.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_TERM_COUNT_CUTOFF

public static int DEFAULT_TERM_COUNT_CUTOFF

DEFAULT_DOC_COUNT_PERCENT

public static double DEFAULT_DOC_COUNT_PERCENT
Constructor Detail

MultiTermQuery.ConstantScoreAutoRewrite

public MultiTermQuery.ConstantScoreAutoRewrite()
Method Detail

setTermCountCutoff

public void setTermCountCutoff(int count)
If the number of terms in this query is equal to or larger than this setting then MultiTermQuery.CONSTANT_SCORE_FILTER_REWRITE is used.


getTermCountCutoff

public int getTermCountCutoff()
See Also:
setTermCountCutoff(int)

setDocCountPercent

public void setDocCountPercent(double percent)
If the number of documents to be visited in the postings exceeds this specified percentage of the maxDoc() for the index, then MultiTermQuery.CONSTANT_SCORE_FILTER_REWRITE is used.

Parameters:
percent - 0.0 to 100.0

getDocCountPercent

public double getDocCountPercent()
See Also:
setDocCountPercent(double)

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


rewrite

public Query 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

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.