CreateWeight() public method

Expert: Constructs an appropriate Weight implementation for this query.

Only implemented by primitive queries, which re-write to themselves.

public CreateWeight ( IndexSearcher searcher ) : Weight
searcher IndexSearcher
return Weight
Beispiel #1
0
        /// <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));
        }
Beispiel #2
0
        /// <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));
        }
Beispiel #3
0
        /// <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);
        }
Beispiel #4
0
        /// <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);
        }
Beispiel #5
0
        /// <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);
        }
Beispiel #6
0
 public override Weight CreateWeight(IndexSearcher searcher)
 {
     return(AssertingWeight.Wrap(new Random(Random.Next()), @in.CreateWeight(searcher)));
 }
Beispiel #7
0
 public override Weight CreateWeight(IndexSearcher searcher)
 {
     return(AssertingWeight.Wrap(new J2N.Randomizer(random.NextInt64()), @in.CreateWeight(searcher)));
 }