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

java.lang.Object
  extended by org.apache.lucene.search.MultiTermQuery.RewriteMethod
      extended by org.apache.lucene.search.ScoringRewrite<Q>
All Implemented Interfaces:
Serializable

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

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
           
 
Field Summary
static MultiTermQuery.RewriteMethod CONSTANT_SCORE_BOOLEAN_QUERY_REWRITE
          Like SCORING_BOOLEAN_QUERY_REWRITE except scores are not computed.
static ScoringRewrite<BooleanQuery> SCORING_BOOLEAN_QUERY_REWRITE
          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.
 
Constructor Summary
ScoringRewrite()
           
 
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)
           
protected abstract  Q getTopLevelQuery()
          Return a suitable top-level Query for holding all expanded terms.
 Q rewrite(IndexReader reader, MultiTermQuery query)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SCORING_BOOLEAN_QUERY_REWRITE

public static final ScoringRewrite<BooleanQuery> SCORING_BOOLEAN_QUERY_REWRITE
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. Note that typically such scores are meaningless to the user, and require non-trivial CPU to compute, so it's almost always better to use MultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT instead.

NOTE: This rewrite method will hit BooleanQuery.TooManyClauses if the number of terms exceeds BooleanQuery.getMaxClauseCount().

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

CONSTANT_SCORE_BOOLEAN_QUERY_REWRITE

public static final MultiTermQuery.RewriteMethod CONSTANT_SCORE_BOOLEAN_QUERY_REWRITE
Like SCORING_BOOLEAN_QUERY_REWRITE except scores are not computed. Instead, each matching document receives a constant score equal to the query's boost.

NOTE: This rewrite method will hit BooleanQuery.TooManyClauses if the number of terms exceeds BooleanQuery.getMaxClauseCount().

See Also:
MultiTermQuery.setRewriteMethod(org.apache.lucene.search.MultiTermQuery.RewriteMethod)
Constructor Detail

ScoringRewrite

public ScoringRewrite()
Method Detail

rewrite

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

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.