Class Weight

java.lang.Object
org.apache.lucene.search.Weight
All Implemented Interfaces:
SegmentCacheable
Direct Known Subclasses:
ConstantScoreWeight, DisjunctionMaxQuery.DisjunctionMaxWeight, FilterWeight, IndriAndWeight, PhraseWeight

public abstract class Weight extends Object implements SegmentCacheable
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.

IndexSearcher dependent state of the query should reside in the Weight.

LeafReader dependent state should reside in the Scorer.

Since Weight creates Scorer instances for a given LeafReaderContext (scorer(org.apache.lucene.index.LeafReaderContext)) callers must maintain the relationship between the searcher's top-level IndexReaderContext and the context used to create a Scorer.

A Weight is used in the following way:

  1. A Weight is constructed by a top-level query, given a IndexSearcher (Query.createWeight(IndexSearcher, ScoreMode, float)).
  2. A Scorer is constructed by scorer(org.apache.lucene.index.LeafReaderContext).
Since:
2.9