Ejemplo n.º 1
0
 public override float GetValueForNormalization()
 {
     // we calculate sumOfSquaredWeights of the inner weight, but ignore it (just to initialize everything)
     if (innerWeight != null)
     {
         innerWeight.GetValueForNormalization();
     }
     queryWeight = outerInstance.Boost;
     return(queryWeight * queryWeight);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a normalized weight for a top-level <see cref="Query"/>.
        /// The query is rewritten by this method and <see cref="Query.CreateWeight(IndexSearcher)"/> called,
        /// afterwards the <see cref="Weight"/> is normalized. The returned <see cref="Weight"/>
        /// can then directly be used to get a <see cref="Scorer"/>.
        /// <para/>
        /// @lucene.internal
        /// </summary>
        public virtual Weight CreateNormalizedWeight(Query query)
        {
            query = Rewrite(query);
            Weight weight = query.CreateWeight(this);
            float  v      = weight.GetValueForNormalization();
            float  norm   = Similarity.QueryNorm(v);

            if (float.IsInfinity(norm) || float.IsNaN(norm))
            {
                norm = 1.0f;
            }
            weight.Normalize(norm, 1.0f);
            return(weight);
        }
Ejemplo n.º 3
0
 public override float GetValueForNormalization()
 {
     return(weight.GetValueForNormalization() * outerInstance.Boost * outerInstance.Boost); // boost sub-weight
 }