/// <summary> Expert: Constructs and initializes a Weight for a top-level query.</summary>
public virtual Weight Weight(Searcher searcher, IState state)
{
Query query = searcher.Rewrite(this, state);
Weight weight = query.CreateWeight(searcher, state);
float sum = weight.GetSumOfSquaredWeights();
float norm = GetSimilarity(searcher).QueryNorm(sum);
if (float.IsInfinity(norm) || float.IsNaN(norm))
{
norm = 1.0f;
}
weight.Normalize(norm);
return(weight);
}