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:
Weight
is constructed by a top-level query, given a IndexSearcher
( {@link Query#createWeight(IndexSearcher)}). Weight
to compute the query normalization factor {@link Similarity#queryNorm(float)} of the query clauses contained in thequery. Scorer
is constructed by {@link #scorer(AtomicReaderContext,boolean,boolean,Bits)}.
|
|
|
|
|
|