lucene.search.Weight

org.apache.lucene.search 
Class Weight

java.lang.Object
  extended by org.apache.lucene.search.Weight
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
BooleanQuery.BooleanWeightConstantScoreQuery.ConstantWeightDisjunctionMaxQuery.DisjunctionMaxWeightSpanWeight

public abstract class Weight
extends Object
implements Serializable

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.

 

Weight is used in the following way:

  1. 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. Scorer is constructed by scorer(IndexReader,boolean,boolean).



     

猜你喜欢

转载自nemogu.iteye.com/blog/1498115