Only implemented by primitive queries, which re-write to themselves.
/// <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> protected internal override Weight CreateWeight(Searcher searcher) { Weight weight = query.CreateWeight(searcher); Similarity similarity = query.GetSimilarity(searcher); return(new AnonymousClassWeight(weight, similarity, this)); }
/// <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, IState state) { Weight weight = query.CreateWeight(searcher, state); 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); weight.Normalize(norm); return(weight); }
/// <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); }
/// <summary> /// Creates a normalized weight for a top-level <seealso cref="Query"/>. /// The query is rewritten by this method and <seealso cref="Query#createWeight"/> called, /// afterwards the <seealso cref="Weight"/> is normalized. The returned {@code Weight} /// can then directly be used to get a <seealso cref="Scorer"/>. /// @lucene.internal /// </summary> public virtual Weight CreateNormalizedWeight(Query query) { query = Rewrite(query); Weight weight = query.CreateWeight(this); float v = weight.ValueForNormalization; float norm = Similarity.QueryNorm(v); if (float.IsInfinity(norm) || float.IsNaN(norm)) { norm = 1.0f; } weight.Normalize(norm, 1.0f); return(weight); }
public override Weight CreateWeight(IndexSearcher searcher) { return(AssertingWeight.Wrap(new Random(Random.Next()), @in.CreateWeight(searcher))); }
public override Weight CreateWeight(IndexSearcher searcher) { return(AssertingWeight.Wrap(new J2N.Randomizer(random.NextInt64()), @in.CreateWeight(searcher))); }