/// <summary> Returns a Weight that applies the filter to the enclosed query's Weight. /// This is accomplished by overriding the Scorer returned by the Weight. /// </summary> public override Weight CreateWeight(Searcher searcher) { Weight weight = query.CreateWeight(searcher); Similarity similarity = query.GetSimilarity(searcher); return(new AnonymousClassWeight(weight, similarity, this)); }
/// <summary> Expert: Constructs and initializes a Weight for a top-level query.</summary> public virtual Weight Weight(Searcher searcher) { Query query = searcher.Rewrite(this); Weight weight = query.CreateWeight(searcher); float sum = weight.SumOfSquaredWeights(); float norm = GetSimilarity(searcher).QueryNorm(sum); if (float.IsInfinity(norm) || float.IsNaN(norm)) { norm = 1.0f; } weight.Normalize(norm); return(weight); }