Expert: Calculate query weights and build query scorers.
The purpose of {@link Weight} is to ensure searching does not modify a{@link Query}, so that a {@link Query} instance can be reused.
{@link IndexSearcher} dependent state of the query should reside in the{@link Weight}.
{@link AtomicReader} dependent state should reside in the {@link Scorer}.
Since {@link Weight} creates {@link Scorer} instances for a given{@link AtomicReaderContext} ({@link #scorer(AtomicReaderContext,boolean,boolean,Bits)}) callers must maintain the relationship between the searcher's top-level {@link IndexReaderContext} and the context used to create a {@link Scorer}.
A Weight
is used in the following way:
- A
Weight
is constructed by a top-level query, given a IndexSearcher
( {@link Query#createWeight(IndexSearcher)}). - The {@link #getValueForNormalization()} method is called on the
Weight
to compute the query normalization factor {@link Similarity#queryNorm(float)} of the query clauses contained in thequery. - The query normalization factor is passed to {@link #normalize(float,float)}. At this point the weighting is complete.
- A
Scorer
is constructed by {@link #scorer(AtomicReaderContext,boolean,boolean,Bits)}.
@since 2.9