Home » lucene-3.0.1-src » org.apache » lucene » search » [javadoc | source]
org.apache.lucene.search
abstract public class: Weight [javadoc | source]
java.lang.Object
   org.apache.lucene.search.Weight

All Implemented Interfaces:
    Serializable

Direct Known Subclasses:
    BooleanWeight, ConstantWeight, CustomWeight, TermWeight, PhrasePrefixWeight, DisjunctionMaxWeight, SpanWeight, PhraseWeight, BoostingTermWeight, MatchAllDocsWeight, MultiPhraseWeight, ValueSourceWeight, PayloadNearSpanWeight, PayloadTermWeight

Expert: Calculate query weights and build query scorers.

The purpose of Weight is to ensure searching does not modify a Query , so that a Query instance can be reused.
Searcher dependent state of the query should reside in the Weight .
IndexReader dependent state should reside in the Scorer .

A Weight is used in the following way:

  1. A Weight is constructed by a top-level query, given a Searcher (Query#createWeight(Searcher) ).
  2. The #sumOfSquaredWeights() method is called on the Weight to compute the query normalization factor Similarity#queryNorm(float) of the query clauses contained in the query.
  3. The query normalization factor is passed to #normalize(float) . At this point the weighting is complete.
  4. A Scorer is constructed by #scorer(IndexReader,boolean,boolean) .
Method from org.apache.lucene.search.Weight Summary:
explain,   getQuery,   getValue,   normalize,   scorer,   scoresDocsOutOfOrder,   sumOfSquaredWeights
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.lucene.search.Weight Detail:
 abstract public Explanation explain(IndexReader reader,
    int doc) throws IOException
    An explanation of the score computation for the named document.
 abstract public Query getQuery()
    The query that this concerns.
 abstract public float getValue()
    The weight for this query.
 abstract public  void normalize(float norm)
    Assigns the query normalization factor to this.
 abstract public Scorer scorer(IndexReader reader,
    boolean scoreDocsInOrder,
    boolean topScorer) throws IOException
    Returns a Scorer which scores documents in/out-of order according to scoreDocsInOrder.

    NOTE: even if scoreDocsInOrder is false, it is recommended to check whether the returned Scorer indeed scores documents out of order (i.e., call #scoresDocsOutOfOrder() ), as some Scorer implementations will always return documents in-order.
    NOTE: null can be returned if no documents will be scored by this query.

 public boolean scoresDocsOutOfOrder() 
 abstract public float sumOfSquaredWeights() throws IOException
    The sum of squared weights of contained query clauses.