Exemplo n.º 1
0
            public override Explanation Explain(IndexReader reader, int doc, IState state)
            {
                var  cs     = new ConstantScorer(enclosingInstance, similarity, reader, this, state);
                bool exists = cs.docIdSetIterator.Advance(doc, state) == doc;

                var result = new ComplexExplanation();

                if (exists)
                {
                    result.Description = "ConstantScoreQuery(" + Enclosing_Instance.internalFilter + "), product of:";
                    result.Value       = queryWeight;
                    System.Boolean tempAux = true;
                    result.Match = tempAux;
                    result.AddDetail(new Explanation(Enclosing_Instance.Boost, "boost"));
                    result.AddDetail(new Explanation(queryNorm, "queryNorm"));
                }
                else
                {
                    result.Description = "ConstantScoreQuery(" + Enclosing_Instance.internalFilter + ") doesn't match id " + doc;
                    result.Value       = 0;
                    System.Boolean tempAux2 = false;
                    result.Match = tempAux2;
                }
                return(result);
            }
Exemplo n.º 2
0
            public virtual Explanation Explain(IndexReader reader, int doc)
            {
                ConstantScorer cs     = (ConstantScorer)Scorer(reader);
                bool           exists = cs.bits.Get(doc);

                ComplexExplanation result = new ComplexExplanation();

                if (exists)
                {
                    result.SetDescription("ConstantScoreQuery(" + Enclosing_Instance.filter + "), product of:");
                    result.SetValue(queryWeight);
                    System.Boolean tempAux = true;
                    result.SetMatch(tempAux);
                    result.AddDetail(new Explanation(Enclosing_Instance.GetBoost(), "boost"));
                    result.AddDetail(new Explanation(queryNorm, "queryNorm"));
                }
                else
                {
                    result.SetDescription("ConstantScoreQuery(" + Enclosing_Instance.filter + ") doesn't match id " + doc);
                    result.SetValue(0);
                    System.Boolean tempAux2 = false;
                    result.SetMatch(tempAux2);
                }
                return(result);
            }
Exemplo n.º 3
0
            public override Explanation Explain(IndexReader reader, int doc)
            {
                ConstantScorer cs     = new ConstantScorer(enclosingInstance, similarity, reader, this);
                bool           exists = cs.docIdSetIterator.Advance(doc) == doc;

                ComplexExplanation result = new ComplexExplanation();

                if (exists)
                {
                    result.SetDescription("ConstantScoreQuery(" + Enclosing_Instance.filter + "), product of:");
                    result.SetValue(queryWeight);
                    System.Boolean tempAux = true;
                    result.SetMatch(tempAux);
                    result.AddDetail(new Explanation(Enclosing_Instance.GetBoost(), "boost"));
                    result.AddDetail(new Explanation(queryNorm, "queryNorm"));
                }
                else
                {
                    result.SetDescription("ConstantScoreQuery(" + Enclosing_Instance.filter + ") doesn't match id " + doc);
                    result.SetValue(0);
                    System.Boolean tempAux2 = false;
                    result.SetMatch(tempAux2);
                }
                return(result);
            }
Exemplo n.º 4
0
            public override Explanation Explain(AtomicReaderContext context, int doc)
            {
                // explain query weight
                Explanation queryExpl = new ComplexExplanation(true, queryWeight, "MatchAllDocsQuery, product of:");

                if (outerInstance.Boost != 1.0f)
                {
                    queryExpl.AddDetail(new Explanation(outerInstance.Boost, "boost"));
                }
                queryExpl.AddDetail(new Explanation(queryNorm, "queryNorm"));

                return(queryExpl);
            }
Exemplo n.º 5
0
            public override Explanation Explain(IndexReader reader, int doc)
            {
                // explain query weight
                Explanation queryExpl = new ComplexExplanation(true, this.Value, "docset query, product of:");
                float boost = _query.Boost;
                if (boost != 1.0f)
                {
                    queryExpl.AddDetail(new Explanation(boost, "boost"));
                }
                queryExpl.AddDetail(new Explanation(_queryNorm, "queryNorm"));

                return queryExpl;
            }
Exemplo n.º 6
0
            public override Explanation Explain(IndexReader reader, int doc)
            {
                // explain query weight
                Explanation queryExpl = new ComplexExplanation(true, GetValue(), "MatchAllDocsQuery, product of:");

                if (Enclosing_Instance.GetBoost() != 1.0f)
                {
                    queryExpl.AddDetail(new Explanation(Enclosing_Instance.GetBoost(), "boost"));
                }
                queryExpl.AddDetail(new Explanation(queryNorm, "queryNorm"));

                return(queryExpl);
            }
Exemplo n.º 7
0
            /* Explain the score we computed for doc */
            public override Explanation Explain(IndexReader reader, int doc)
            {
                if (Enclosing_Instance.disjuncts.Count == 1)
                {
                    return(((Weight)weights[0]).Explain(reader, doc));
                }
                ComplexExplanation result = new ComplexExplanation();
                float max = 0.0f, sum = 0.0f;

                result.SetDescription(Enclosing_Instance.tieBreakerMultiplier == 0.0f?"max of:":"max plus " + Enclosing_Instance.tieBreakerMultiplier + " times others of:");
                for (System.Collections.IEnumerator iter = weights.GetEnumerator(); iter.MoveNext();)
                {
                    Explanation e = ((Weight)iter.Current).Explain(reader, doc);
                    if (e.IsMatch())
                    {
                        System.Boolean tempAux = true;
                        result.SetMatch(tempAux);
                        result.AddDetail(e);
                        sum += e.GetValue();
                        max  = System.Math.Max(max, e.GetValue());
                    }
                }
                result.SetValue(max + (sum - max) * Enclosing_Instance.tieBreakerMultiplier);
                return(result);
            }
Exemplo n.º 8
0
            /* Explain the score we computed for doc */
            public override Explanation Explain(IndexReader reader, int doc, IState state)
            {
                if (Enclosing_Instance.disjuncts.Count == 1)
                {
                    return(weights[0].Explain(reader, doc, state));
                }
                ComplexExplanation result = new ComplexExplanation();
                float max = 0.0f, sum = 0.0f;

                result.Description = Enclosing_Instance.tieBreakerMultiplier == 0.0f?"max of:":"max plus " + Enclosing_Instance.tieBreakerMultiplier + " times others of:";
                foreach (Weight wt in weights)
                {
                    Explanation e = wt.Explain(reader, doc, state);
                    if (e.IsMatch)
                    {
                        System.Boolean tempAux = true;
                        result.Match = tempAux;
                        result.AddDetail(e);
                        sum += e.Value;
                        max  = System.Math.Max(max, e.Value);
                    }
                }
                result.Value = max + (sum - max) * Enclosing_Instance.tieBreakerMultiplier;
                return(result);
            }
Exemplo n.º 9
0
            /* Explain the score we computed for doc */
            public virtual Explanation Explain(IndexReader reader, int doc)
            {
                if (Enclosing_Instance.disjuncts.Count == 1)
                {
                    return(((Weight)weights[0]).Explain(reader, doc));
                }
                ComplexExplanation result = new ComplexExplanation();
                float max = 0.0f, sum = 0.0f;

                result.SetDescription(Enclosing_Instance.tieBreakerMultiplier == 0.0f ? "max of:" : "max plus " + Enclosing_Instance.tieBreakerMultiplier + " times others of:");
                for (int i = 0; i < weights.Count; i++)
                {
                    Explanation e = ((Weight)weights[i]).Explain(reader, doc);
                    if (e.IsMatch())
                    {
                        System.Boolean tempAux = true;
                        result.SetMatch(tempAux);
                        result.AddDetail(e);
                        sum += e.GetValue();
                        max  = System.Math.Max(max, e.GetValue());
                    }
                }
                result.SetValue(max + (sum - max) * Enclosing_Instance.tieBreakerMultiplier);
                return(result);
            }
Exemplo n.º 10
0
            public override Explanation Explain(AtomicReaderContext context, int doc)
            {
                Scorer cs     = GetScorer(context, (context.AtomicReader).LiveDocs);
                bool   exists = (cs != null && cs.Advance(doc) == doc);

                ComplexExplanation result = new ComplexExplanation();

                if (exists)
                {
                    result.Description = outerInstance.ToString() + ", product of:";
                    result.Value       = queryWeight;
                    result.Match       = true;
                    result.AddDetail(new Explanation(outerInstance.Boost, "boost"));
                    result.AddDetail(new Explanation(queryNorm, "queryNorm"));
                }
                else
                {
                    result.Description = outerInstance.ToString() + " doesn't match id " + doc;
                    result.Value       = 0;
                    result.Match       = false;
                }
                return(result);
            }
Exemplo n.º 11
0
            public override Explanation Explain(AtomicReaderContext context, int doc)
            {
                Scorer scorer = GetScorer(context, context.AtomicReader.LiveDocs);

                if (scorer != null)
                {
                    int newDoc = scorer.Advance(doc);
                    if (newDoc == doc)
                    {
                        float              freq      = scorer.Freq;
                        SimScorer          docScorer = similarity.GetSimScorer(stats, context);
                        ComplexExplanation result    = new ComplexExplanation();
                        result.Description = "weight(" + Query + " in " + doc + ") [" + similarity.GetType().Name + "], result of:";
                        Explanation scoreExplanation = docScorer.Explain(doc, new Explanation(freq, "termFreq=" + freq));
                        result.AddDetail(scoreExplanation);
                        result.Value = scoreExplanation.Value;
                        result.Match = true;
                        return(result);
                    }
                }
                return(new ComplexExplanation(false, 0.0f, "no matching term"));
            }
Exemplo n.º 12
0
            public override Explanation Explain(AtomicReaderContext context, int doc)
            {
                Scorer scorer = Scorer(context, (context.AtomicReader).LiveDocs);

                if (scorer != null)
                {
                    int newDoc = scorer.Advance(doc);
                    if (newDoc == doc)
                    {
                        float              freq      = OuterInstance.slop == 0 ? scorer.Freq() : ((SloppyPhraseScorer)scorer).SloppyFreq();
                        SimScorer          docScorer = Similarity.DoSimScorer(Stats, context);
                        ComplexExplanation result    = new ComplexExplanation();
                        result.Description = "weight(" + Query + " in " + doc + ") [" + Similarity.GetType().Name + "], result of:";
                        Explanation scoreExplanation = docScorer.Explain(doc, new Explanation(freq, "phraseFreq=" + freq));
                        result.AddDetail(scoreExplanation);
                        result.Value = scoreExplanation.Value;
                        result.Match = true;
                        return(result);
                    }
                }

                return(new ComplexExplanation(false, 0.0f, "no matching term"));
            }
Exemplo n.º 13
0
            /// <summary>
            /// Explain the score we computed for doc </summary>
            public override Explanation Explain(AtomicReaderContext context, int doc)
            {
                if (outerInstance.disjuncts.Count == 1)
                {
                    return(m_weights[0].Explain(context, doc));
                }
                ComplexExplanation result = new ComplexExplanation();
                float max = 0.0f, sum = 0.0f;

                result.Description = outerInstance.tieBreakerMultiplier == 0.0f ? "max of:" : "max plus " + outerInstance.tieBreakerMultiplier + " times others of:";
                foreach (Weight wt in m_weights)
                {
                    Explanation e = wt.Explain(context, doc);
                    if (e.IsMatch)
                    {
                        result.Match = true;
                        result.AddDetail(e);
                        sum += e.Value;
                        max  = Math.Max(max, e.Value);
                    }
                }
                result.Value = max + (sum - max) * outerInstance.tieBreakerMultiplier;
                return(result);
            }
Exemplo n.º 14
0
            public override Explanation Explain(AtomicReaderContext context, int doc)
            {
                Scorer cs = Scorer(context, (context.AtomicReader).LiveDocs);
                bool exists = (cs != null && cs.Advance(doc) == doc);

                ComplexExplanation result = new ComplexExplanation();
                if (exists)
                {
                    result.Description = OuterInstance.ToString() + ", product of:";
                    result.Value = QueryWeight;
                    result.Match = true;
                    result.AddDetail(new Explanation(OuterInstance.Boost, "boost"));
                    result.AddDetail(new Explanation(QueryNorm, "queryNorm"));
                }
                else
                {
                    result.Description = OuterInstance.ToString() + " doesn't match id " + doc;
                    result.Value = 0;
                    result.Match = false;
                }
                return result;
            }
Exemplo n.º 15
0
			public /*override*/ Explanation Explain(int doc)
			{
				float sc = qWeight * vals.FloatVal(doc);

				Explanation result = new ComplexExplanation
				  (true, sc, "FunctionQuery(" + ((FunctionQuery)weight.Query).func + "), product of:");

				result.AddDetail(vals.Explain(doc));
				result.AddDetail(new Explanation(weight.Query.Boost, "boost"));
				result.AddDetail(new Explanation(weight.GetQueryNorm(), "queryNorm"));
				return result;
			}
Exemplo n.º 16
0
            public override Explanation Explain(IndexReader reader, int doc)
            {
                ComplexExplanation result = new ComplexExplanation();

                result.Description = "weight(" + Query + " in " + doc + "), product of:";

                Explanation expl = new Explanation(idf, idfExp.Explain());

                // explain query weight
                Explanation queryExpl = new Explanation();

                queryExpl.Description = "queryWeight(" + Query + "), product of:";

                Explanation boostExpl = new Explanation(Enclosing_Instance.Boost, "boost");

                if (Enclosing_Instance.Boost != 1.0f)
                {
                    queryExpl.AddDetail(boostExpl);
                }
                queryExpl.AddDetail(expl);

                Explanation queryNormExpl = new Explanation(queryNorm, "queryNorm");

                queryExpl.AddDetail(queryNormExpl);

                queryExpl.Value = boostExpl.Value * expl.Value * queryNormExpl.Value;

                result.AddDetail(queryExpl);

                // explain field weight
                string             field     = Enclosing_Instance.term.Field;
                ComplexExplanation fieldExpl = new ComplexExplanation();

                fieldExpl.Description = "fieldWeight(" + Enclosing_Instance.term + " in " + doc + "), product of:";

                Explanation tfExplanation = new Explanation();
                int         tf            = 0;
                TermDocs    termDocs      = reader.TermDocs(enclosingInstance.term);

                if (termDocs != null)
                {
                    try
                    {
                        if (termDocs.SkipTo(doc) && termDocs.Doc == doc)
                        {
                            tf = termDocs.Freq;
                        }
                    }
                    finally
                    {
                        termDocs.Close();
                    }
                    tfExplanation.Value       = similarity.Tf(tf);
                    tfExplanation.Description = "tf(termFreq(" + enclosingInstance.term + ")=" + tf + ")";
                }
                else
                {
                    tfExplanation.Value       = 0.0f;
                    tfExplanation.Description = "no matching term";
                }
                fieldExpl.AddDetail(tfExplanation);
                fieldExpl.AddDetail(expl);

                Explanation fieldNormExpl = new Explanation();

                byte[] fieldNorms = reader.Norms(field);
                float  fieldNorm  = fieldNorms != null?Similarity.DecodeNorm(fieldNorms[doc]) : 1.0f;

                fieldNormExpl.Value       = fieldNorm;
                fieldNormExpl.Description = "fieldNorm(field=" + field + ", doc=" + doc + ")";
                fieldExpl.AddDetail(fieldNormExpl);

                fieldExpl.Match = tfExplanation.IsMatch;
                fieldExpl.Value = tfExplanation.Value * expl.Value * fieldNormExpl.Value;

                result.AddDetail(fieldExpl);
                bool?tempAux = fieldExpl.Match;

                result.Match = tempAux;

                // combine them
                result.Value = queryExpl.Value * fieldExpl.Value;

                if (queryExpl.Value == 1.0f)
                {
                    return(fieldExpl);
                }

                return(result);
            }
Exemplo n.º 17
0
 public override Explanation Explain(IndexReader reader, int doc)
 {
     
     ComplexExplanation result = new ComplexExplanation();
     result.Description = "weight(" + Query + " in " + doc + "), product of:";
     System.String field = ((SpanQuery) Query).Field;
     
     Explanation idfExpl = new Explanation(idf, "idf(" + field + ": " + idfExp.Explain() + ")");
     
     // explain query weight
     Explanation queryExpl = new Explanation();
     queryExpl.Description = "queryWeight(" + Query + "), product of:";
     
     Explanation boostExpl = new Explanation(Query.Boost, "boost");
     if (Query.Boost != 1.0f)
         queryExpl.AddDetail(boostExpl);
     queryExpl.AddDetail(idfExpl);
     
     Explanation queryNormExpl = new Explanation(queryNorm, "queryNorm");
     queryExpl.AddDetail(queryNormExpl);
     
     queryExpl.Value = boostExpl.Value * idfExpl.Value * queryNormExpl.Value;
     
     result.AddDetail(queryExpl);
     
     // explain field weight
     ComplexExplanation fieldExpl = new ComplexExplanation();
     fieldExpl.Description = "fieldWeight(" + field + ":" + internalQuery.ToString(field) + " in " + doc + "), product of:";
     
     Explanation tfExpl = ((SpanScorer)Scorer(reader, true, false)).Explain(doc);
     fieldExpl.AddDetail(tfExpl);
     fieldExpl.AddDetail(idfExpl);
     
     Explanation fieldNormExpl = new Explanation();
     byte[] fieldNorms = reader.Norms(field);
     float fieldNorm = fieldNorms != null?Similarity.DecodeNorm(fieldNorms[doc]):1.0f;
     fieldNormExpl.Value = fieldNorm;
     fieldNormExpl.Description = "fieldNorm(field=" + field + ", doc=" + doc + ")";
     fieldExpl.AddDetail(fieldNormExpl);
     
     fieldExpl.Match = tfExpl.IsMatch;
     fieldExpl.Value = tfExpl.Value * idfExpl.Value * fieldNormExpl.Value;
     
     result.AddDetail(fieldExpl);
     System.Boolean? tempAux = fieldExpl.Match;
     result.Match = tempAux;
     
     // combine them
     result.Value = queryExpl.Value * fieldExpl.Value;
     
     if (queryExpl.Value == 1.0f)
         return fieldExpl;
     
     return result;
 }
Exemplo n.º 18
0
		public override Explanation Explain(IndexReader reader, int doc)
		{
			
			ComplexExplanation result = new ComplexExplanation();
			result.SetDescription("weight(" + GetQuery() + " in " + doc + "), product of:");
			System.String field = ((SpanQuery) GetQuery()).GetField();
			
			Explanation idfExpl = new Explanation(idf, "idf(" + field + ": " + idfExp.Explain() + ")");
			
			// explain query weight
			Explanation queryExpl = new Explanation();
			queryExpl.SetDescription("queryWeight(" + GetQuery() + "), product of:");
			
			Explanation boostExpl = new Explanation(GetQuery().GetBoost(), "boost");
			if (GetQuery().GetBoost() != 1.0f)
				queryExpl.AddDetail(boostExpl);
			queryExpl.AddDetail(idfExpl);
			
			Explanation queryNormExpl = new Explanation(queryNorm, "queryNorm");
			queryExpl.AddDetail(queryNormExpl);
			
			queryExpl.SetValue(boostExpl.GetValue() * idfExpl.GetValue() * queryNormExpl.GetValue());
			
			result.AddDetail(queryExpl);
			
			// explain field weight
			ComplexExplanation fieldExpl = new ComplexExplanation();
			fieldExpl.SetDescription("fieldWeight(" + field + ":" + query.ToString(field) + " in " + doc + "), product of:");
			
			Explanation tfExpl = Scorer(reader, true, false).Explain(doc);
			fieldExpl.AddDetail(tfExpl);
			fieldExpl.AddDetail(idfExpl);
			
			Explanation fieldNormExpl = new Explanation();
			byte[] fieldNorms = reader.Norms(field);
			float fieldNorm = fieldNorms != null?Similarity.DecodeNorm(fieldNorms[doc]):1.0f;
			fieldNormExpl.SetValue(fieldNorm);
			fieldNormExpl.SetDescription("fieldNorm(field=" + field + ", doc=" + doc + ")");
			fieldExpl.AddDetail(fieldNormExpl);
			
			fieldExpl.SetMatch(tfExpl.IsMatch());
			fieldExpl.SetValue(tfExpl.GetValue() * idfExpl.GetValue() * fieldNormExpl.GetValue());
			
			result.AddDetail(fieldExpl);
			System.Boolean? tempAux = fieldExpl.GetMatch();
			result.SetMatch(tempAux);
			
			// combine them
			result.SetValue(queryExpl.GetValue() * fieldExpl.GetValue());
			
			if (queryExpl.GetValue() == 1.0f)
				return fieldExpl;
			
			return result;
		}
Exemplo n.º 19
0
            public override Explanation Explain(IndexReader reader, int doc)
            {
                int minShouldMatch         = Enclosing_Instance.GetMinimumNumberShouldMatch();
                ComplexExplanation sumExpl = new ComplexExplanation();

                sumExpl.SetDescription("sum of:");
                int   coord            = 0;
                int   maxCoord         = 0;
                float sum              = 0.0f;
                bool  fail             = false;
                int   shouldMatchCount = 0;

                for (System.Collections.IEnumerator wIter = weights.GetEnumerator(), cIter = Enclosing_Instance.clauses.GetEnumerator(); wIter.MoveNext();)
                {
                    cIter.MoveNext();

                    Weight        w = (Weight)wIter.Current;
                    BooleanClause c = (BooleanClause)cIter.Current;
                    if (w.Scorer(reader, true, true) == null)
                    {
                        continue;
                    }
                    Explanation e = w.Explain(reader, doc);
                    if (!c.IsProhibited())
                    {
                        maxCoord++;
                    }
                    if (e.IsMatch())
                    {
                        if (!c.IsProhibited())
                        {
                            sumExpl.AddDetail(e);
                            sum += e.GetValue();
                            coord++;
                        }
                        else
                        {
                            Explanation r = new Explanation(0.0f, "match on prohibited clause (" + c.GetQuery().ToString() + ")");
                            r.AddDetail(e);
                            sumExpl.AddDetail(r);
                            fail = true;
                        }
                        if (c.GetOccur() == Occur.SHOULD)
                        {
                            shouldMatchCount++;
                        }
                    }
                    else if (c.IsRequired())
                    {
                        Explanation r = new Explanation(0.0f, "no match on required clause (" + c.GetQuery().ToString() + ")");
                        r.AddDetail(e);
                        sumExpl.AddDetail(r);
                        fail = true;
                    }
                }
                if (fail)
                {
                    System.Boolean tempAux = false;
                    sumExpl.SetMatch(tempAux);
                    sumExpl.SetValue(0.0f);
                    sumExpl.SetDescription("Failure to meet condition(s) of required/prohibited clause(s)");
                    return(sumExpl);
                }
                else if (shouldMatchCount < minShouldMatch)
                {
                    System.Boolean tempAux2 = false;
                    sumExpl.SetMatch(tempAux2);
                    sumExpl.SetValue(0.0f);
                    sumExpl.SetDescription("Failure to match minimum number " + "of optional clauses: " + minShouldMatch);
                    return(sumExpl);
                }

                sumExpl.SetMatch(0 < coord?true:false);
                sumExpl.SetValue(sum);

                float coordFactor = similarity.Coord(coord, maxCoord);

                if (coordFactor == 1.0f)
                {
                    // coord is no-op
                    return(sumExpl);
                }
                // eliminate wrapper
                else
                {
                    ComplexExplanation result = new ComplexExplanation(sumExpl.IsMatch(), sum * coordFactor, "product of:");
                    result.AddDetail(sumExpl);
                    result.AddDetail(new Explanation(coordFactor, "coord(" + coord + "/" + maxCoord + ")"));
                    return(result);
                }
            }
Exemplo n.º 20
0
        public virtual Explanation Explain(IndexReader reader, int doc)
        {
            ComplexExplanation result = new ComplexExplanation();
            result.SetDescription("weight(" + GetQuery() + " in " + doc + "), product of:");
            System.String field = ((SpanQuery) GetQuery()).GetField();

            System.Text.StringBuilder docFreqs = new System.Text.StringBuilder();
            System.Collections.IEnumerator i = terms.GetEnumerator();
            while (i.MoveNext())
            {
                System.Collections.DictionaryEntry tmp = (System.Collections.DictionaryEntry) i.Current;
                Term term = (Term) tmp.Key;
                docFreqs.Append(term.Text());
                docFreqs.Append("=");
                docFreqs.Append(reader.DocFreq(term));

                if (i.MoveNext())
                {
                    docFreqs.Append(" ");
                }
            }

            Explanation idfExpl = new Explanation(idf, "idf(" + field + ": " + docFreqs + ")");

            // explain query weight
            Explanation queryExpl = new Explanation();
            queryExpl.SetDescription("queryWeight(" + GetQuery() + "), product of:");

            Explanation boostExpl = new Explanation(GetQuery().GetBoost(), "boost");
            if (GetQuery().GetBoost() != 1.0f)
                queryExpl.AddDetail(boostExpl);
            queryExpl.AddDetail(idfExpl);

            Explanation queryNormExpl = new Explanation(queryNorm, "queryNorm");
            queryExpl.AddDetail(queryNormExpl);

            queryExpl.SetValue(boostExpl.GetValue() * idfExpl.GetValue() * queryNormExpl.GetValue());

            result.AddDetail(queryExpl);

            // explain field weight
            ComplexExplanation fieldExpl = new ComplexExplanation();
            fieldExpl.SetDescription("fieldWeight(" + field + ":" + query.ToString(field) + " in " + doc + "), product of:");

            Explanation tfExpl = Scorer(reader).Explain(doc);
            fieldExpl.AddDetail(tfExpl);
            fieldExpl.AddDetail(idfExpl);

            Explanation fieldNormExpl = new Explanation();
            byte[] fieldNorms = reader.Norms(field);
            float fieldNorm = fieldNorms != null ? Similarity.DecodeNorm(fieldNorms[doc]) : 0.0f;
            fieldNormExpl.SetValue(fieldNorm);
            fieldNormExpl.SetDescription("fieldNorm(field=" + field + ", doc=" + doc + ")");
            fieldExpl.AddDetail(fieldNormExpl);

            fieldExpl.SetMatch(tfExpl.IsMatch());
            fieldExpl.SetValue(tfExpl.GetValue() * idfExpl.GetValue() * fieldNormExpl.GetValue());

            result.AddDetail(fieldExpl);
            System.Boolean tempAux = fieldExpl.GetMatch();
            result.SetMatch(tempAux);

            // combine them
            result.SetValue(queryExpl.GetValue() * fieldExpl.GetValue());

            if (queryExpl.GetValue() == 1.0f)
                return fieldExpl;

            return result;
        }
Exemplo n.º 21
0
            public virtual Explanation Explain(IndexReader reader, int doc)
            {
                ComplexExplanation result = new ComplexExplanation();

                result.SetDescription("weight(" + GetQuery() + " in " + doc + "), product of:");

                Explanation idfExpl = new Explanation(idf, "idf(docFreq=" + reader.DocFreq(Enclosing_Instance.term) + ", numDocs=" + reader.NumDocs() + ")");

                // explain query weight
                Explanation queryExpl = new Explanation();

                queryExpl.SetDescription("queryWeight(" + GetQuery() + "), product of:");

                Explanation boostExpl = new Explanation(Enclosing_Instance.GetBoost(), "boost");

                if (Enclosing_Instance.GetBoost() != 1.0f)
                {
                    queryExpl.AddDetail(boostExpl);
                }
                queryExpl.AddDetail(idfExpl);

                Explanation queryNormExpl = new Explanation(queryNorm, "queryNorm");

                queryExpl.AddDetail(queryNormExpl);

                queryExpl.SetValue(boostExpl.GetValue() * idfExpl.GetValue() * queryNormExpl.GetValue());

                result.AddDetail(queryExpl);

                // explain field weight
                System.String      field     = Enclosing_Instance.term.Field();
                ComplexExplanation fieldExpl = new ComplexExplanation();

                fieldExpl.SetDescription("fieldWeight(" + Enclosing_Instance.term + " in " + doc + "), product of:");

                Explanation tfExpl = Scorer(reader).Explain(doc);

                fieldExpl.AddDetail(tfExpl);
                fieldExpl.AddDetail(idfExpl);

                Explanation fieldNormExpl = new Explanation();

                byte[] fieldNorms = reader.Norms(field);
                float  fieldNorm  = fieldNorms != null?Similarity.DecodeNorm(fieldNorms[doc]) : 0.0f;

                fieldNormExpl.SetValue(fieldNorm);
                fieldNormExpl.SetDescription("fieldNorm(field=" + field + ", doc=" + doc + ")");
                fieldExpl.AddDetail(fieldNormExpl);

                fieldExpl.SetMatch(tfExpl.IsMatch());
                fieldExpl.SetValue(tfExpl.GetValue() * idfExpl.GetValue() * fieldNormExpl.GetValue());

                result.AddDetail(fieldExpl);
                System.Boolean tempAux = fieldExpl.GetMatch();
                result.SetMatch(tempAux);

                // combine them
                result.SetValue(queryExpl.GetValue() * fieldExpl.GetValue());

                if (queryExpl.GetValue() == 1.0f)
                {
                    return(fieldExpl);
                }

                return(result);
            }
Exemplo n.º 22
0
            public override Explanation Explain(IndexReader reader, int doc)
            {
                ComplexExplanation result = new ComplexExplanation();

                result.Description = "weight(" + Query + " in " + doc + "), product of:";

                Explanation idfExpl = new Explanation(idf, "idf(" + Query + ")");

                // explain query weight
                Explanation queryExpl = new Explanation();

                queryExpl.Description = "queryWeight(" + Query + "), product of:";

                Explanation boostExpl = new Explanation(Enclosing_Instance.Boost, "boost");

                if (Enclosing_Instance.Boost != 1.0f)
                {
                    queryExpl.AddDetail(boostExpl);
                }

                queryExpl.AddDetail(idfExpl);

                Explanation queryNormExpl = new Explanation(queryNorm, "queryNorm");

                queryExpl.AddDetail(queryNormExpl);

                queryExpl.Value = boostExpl.Value * idfExpl.Value * queryNormExpl.Value;

                result.AddDetail(queryExpl);

                // explain field weight
                ComplexExplanation fieldExpl = new ComplexExplanation();

                fieldExpl.Description = "fieldWeight(" + Query + " in " + doc + "), product of:";

                PhraseScorer scorer = (PhraseScorer)Scorer(reader, true, false);

                if (scorer == null)
                {
                    return(new Explanation(0.0f, "no matching docs"));
                }
                Explanation tfExplanation = new Explanation();
                int         d             = scorer.Advance(doc);
                float       phraseFreq    = (d == doc) ? scorer.CurrentFreq() : 0.0f;

                tfExplanation.Value       = similarity.Tf(phraseFreq);
                tfExplanation.Description = "tf(phraseFreq=" + phraseFreq + ")";
                fieldExpl.AddDetail(tfExplanation);
                fieldExpl.AddDetail(idfExpl);

                Explanation fieldNormExpl = new Explanation();

                byte[] fieldNorms = reader.Norms(Enclosing_Instance.field);
                float  fieldNorm  = fieldNorms != null?Similarity.DecodeNorm(fieldNorms[doc]) : 1.0f;

                fieldNormExpl.Value       = fieldNorm;
                fieldNormExpl.Description = "fieldNorm(field=" + Enclosing_Instance.field + ", doc=" + doc + ")";
                fieldExpl.AddDetail(fieldNormExpl);

                fieldExpl.Match = tfExplanation.IsMatch;
                fieldExpl.Value = tfExplanation.Value * idfExpl.Value * fieldNormExpl.Value;

                result.AddDetail(fieldExpl);
                bool?tempAux = fieldExpl.Match;

                result.Match = tempAux;

                // combine them
                result.Value = queryExpl.Value * fieldExpl.Value;

                if (queryExpl.Value == 1.0f)
                {
                    return(fieldExpl);
                }

                return(result);
            }
Exemplo n.º 23
0
                public override Explanation Explain(int doc)
                {
                    ComplexExplanation result = new ComplexExplanation();
                    Explanation nonPayloadExpl = base.Explain(doc);
                    result.AddDetail(nonPayloadExpl);
                    //QUESTION: Is there a wau to avoid this skipTo call?  We need to know whether to load the payload or not

                    Explanation payloadBoost = new Explanation();
                    result.AddDetail(payloadBoost);
                    /*
                    if (skipTo(doc) == true) {
                    processPayload();
                    }*/

                    float avgPayloadScore = (payloadsSeen > 0 ? (payloadScore / payloadsSeen) : 1);
                    payloadBoost.SetValue(avgPayloadScore);
                    //GSI: I suppose we could toString the payload, but I don't think that would be a good idea
                    payloadBoost.SetDescription("scorePayload(...)");
                    result.SetValue(nonPayloadExpl.GetValue() * avgPayloadScore);
                    result.SetDescription("btq, product of:");
                    result.SetMatch(nonPayloadExpl.GetValue() == 0 ? false : true); // LUCENE-1303
                    return result;
                }
Exemplo n.º 24
0
            public virtual Explanation Explain(int d)
            {
                float sc = qWeight * vals.FloatVal(d);

                Explanation result = new ComplexExplanation(true, sc, "FunctionQuery(" + outerInstance.func + "), product of:");

                result.AddDetail(vals.Explain(d));
                result.AddDetail(new Explanation(outerInstance.Boost, "boost"));
                result.AddDetail(new Explanation(weight.queryNorm, "queryNorm"));
                return result;
            }
Exemplo n.º 25
0
			/* Explain the score we computed for doc */
			public virtual Explanation Explain(IndexReader reader, int doc)
			{
				if (Enclosing_Instance.disjuncts.Count == 1)
					return ((Weight) weights[0]).Explain(reader, doc);
				ComplexExplanation result = new ComplexExplanation();
				float max = 0.0f, sum = 0.0f;
				result.SetDescription(Enclosing_Instance.tieBreakerMultiplier == 0.0f ? "max of:" : "max plus " + Enclosing_Instance.tieBreakerMultiplier + " times others of:");
				for (int i = 0; i < weights.Count; i++)
				{
					Explanation e = ((Weight) weights[i]).Explain(reader, doc);
					if (e.IsMatch())
					{
						System.Boolean tempAux = true;
						result.SetMatch(tempAux);
						result.AddDetail(e);
						sum += e.GetValue();
						max = System.Math.Max(max, e.GetValue());
					}
				}
				result.SetValue(max + (sum - max) * Enclosing_Instance.tieBreakerMultiplier);
				return result;
			}
			public override Explanation Explain(IndexReader reader, int doc)
			{
				
				var cs = new ConstantScorer(enclosingInstance, similarity, reader, this);
				bool exists = cs.docIdSetIterator.Advance(doc) == doc;
				
				var result = new ComplexExplanation();
				
				if (exists)
				{
					result.Description = "ConstantScoreQuery(" + Enclosing_Instance.internalFilter + "), product of:";
					result.Value = queryWeight;
					System.Boolean tempAux = true;
					result.Match = tempAux;
					result.AddDetail(new Explanation(Enclosing_Instance.Boost, "boost"));
					result.AddDetail(new Explanation(queryNorm, "queryNorm"));
				}
				else
				{
					result.Description = "ConstantScoreQuery(" + Enclosing_Instance.internalFilter + ") doesn't match id " + doc;
					result.Value = 0;
					System.Boolean tempAux2 = false;
					result.Match = tempAux2;
				}
				return result;
			}
Exemplo n.º 27
0
            public override Explanation Explain(AtomicReaderContext context, int doc)
            {
                int minShouldMatch         = OuterInstance.MinimumNumberShouldMatch;
                ComplexExplanation sumExpl = new ComplexExplanation();

                sumExpl.Description = "sum of:";
                int   coord                       = 0;
                float sum                         = 0.0f;
                bool  fail                        = false;
                int   shouldMatchCount            = 0;
                IEnumerator <BooleanClause> cIter = OuterInstance.clauses.GetEnumerator();

                for (IEnumerator <Weight> wIter = Weights.GetEnumerator(); wIter.MoveNext();)
                {
                    Weight w = wIter.Current;
                    cIter.MoveNext();
                    BooleanClause c = cIter.Current;
                    if (w.Scorer(context, context.AtomicReader.LiveDocs) == null)
                    {
                        if (c.Required)
                        {
                            fail = true;
                            Explanation r = new Explanation(0.0f, "no match on required clause (" + c.Query.ToString() + ")");
                            sumExpl.AddDetail(r);
                        }
                        continue;
                    }
                    Explanation e = w.Explain(context, doc);
                    if (e.IsMatch)
                    {
                        if (!c.Prohibited)
                        {
                            sumExpl.AddDetail(e);
                            sum += e.Value;
                            coord++;
                        }
                        else
                        {
                            Explanation r = new Explanation(0.0f, "match on prohibited clause (" + c.Query.ToString() + ")");
                            r.AddDetail(e);
                            sumExpl.AddDetail(r);
                            fail = true;
                        }
                        if (c.Occur_ == Occur_e.SHOULD)
                        {
                            shouldMatchCount++;
                        }
                    }
                    else if (c.Required)
                    {
                        Explanation r = new Explanation(0.0f, "no match on required clause (" + c.Query.ToString() + ")");
                        r.AddDetail(e);
                        sumExpl.AddDetail(r);
                        fail = true;
                    }
                }
                if (fail)
                {
                    sumExpl.Match       = false;
                    sumExpl.Value       = 0.0f;
                    sumExpl.Description = "Failure to meet condition(s) of required/prohibited clause(s)";
                    return(sumExpl);
                }
                else if (shouldMatchCount < minShouldMatch)
                {
                    sumExpl.Match       = false;
                    sumExpl.Value       = 0.0f;
                    sumExpl.Description = "Failure to match minimum number " + "of optional clauses: " + minShouldMatch;
                    return(sumExpl);
                }

                sumExpl.Match = 0 < coord ? true : false;
                sumExpl.Value = sum;

                float coordFactor = DisableCoord ? 1.0f : Coord(coord, maxCoord);

                if (coordFactor == 1.0f)
                {
                    return(sumExpl); // eliminate wrapper
                }
                else
                {
                    ComplexExplanation result = new ComplexExplanation(sumExpl.IsMatch, sum * coordFactor, "product of:");
                    result.AddDetail(sumExpl);
                    result.AddDetail(new Explanation(coordFactor, "coord(" + coord + "/" + maxCoord + ")"));
                    return(result);
                }
            }
 /* Explain the score we computed for doc */
 public override Explanation Explain(IndexReader reader, int doc)
 {
     if (Enclosing_Instance.disjuncts.Count == 1)
         return ((Weight) weights[0]).Explain(reader, doc);
     ComplexExplanation result = new ComplexExplanation();
     float max = 0.0f, sum = 0.0f;
     result.SetDescription(Enclosing_Instance.tieBreakerMultiplier == 0.0f?"max of:":"max plus " + Enclosing_Instance.tieBreakerMultiplier + " times others of:");
     for (System.Collections.IEnumerator iter = weights.GetEnumerator(); iter.MoveNext(); )
     {
         Explanation e = ((Weight) iter.Current).Explain(reader, doc);
         if (e.IsMatch())
         {
             System.Boolean tempAux = true;
             result.SetMatch(tempAux);
             result.AddDetail(e);
             sum += e.GetValue();
             max = System.Math.Max(max, e.GetValue());
         }
     }
     result.SetValue(max + (sum - max) * Enclosing_Instance.tieBreakerMultiplier);
     return result;
 }
Exemplo n.º 29
0
            public override Explanation Explain(IndexReader reader, int doc)
            {
                ComplexExplanation result = new ComplexExplanation();

                result.SetDescription("weight(" + GetQuery() + " in " + doc + "), product of:");

                Explanation idfExpl = new Explanation(idf, "idf(" + GetQuery() + ")");

                // explain query weight
                Explanation queryExpl = new Explanation();

                queryExpl.SetDescription("queryWeight(" + GetQuery() + "), product of:");

                Explanation boostExpl = new Explanation(Enclosing_Instance.GetBoost(), "boost");

                if (Enclosing_Instance.GetBoost() != 1.0f)
                {
                    queryExpl.AddDetail(boostExpl);
                }

                queryExpl.AddDetail(idfExpl);

                Explanation queryNormExpl = new Explanation(queryNorm, "queryNorm");

                queryExpl.AddDetail(queryNormExpl);

                queryExpl.SetValue(boostExpl.GetValue() * idfExpl.GetValue() * queryNormExpl.GetValue());

                result.AddDetail(queryExpl);

                // explain field weight
                ComplexExplanation fieldExpl = new ComplexExplanation();

                fieldExpl.SetDescription("fieldWeight(" + GetQuery() + " in " + doc + "), product of:");

                Scorer scorer = Scorer(reader, true, false);

                if (scorer == null)
                {
                    return(new Explanation(0.0f, "no matching docs"));
                }
                Explanation tfExpl = scorer.Explain(doc);

                fieldExpl.AddDetail(tfExpl);
                fieldExpl.AddDetail(idfExpl);

                Explanation fieldNormExpl = new Explanation();

                byte[] fieldNorms = reader.Norms(Enclosing_Instance.field);
                float  fieldNorm  = fieldNorms != null?Similarity.DecodeNorm(fieldNorms[doc]) : 1.0f;

                fieldNormExpl.SetValue(fieldNorm);
                fieldNormExpl.SetDescription("fieldNorm(field=" + Enclosing_Instance.field + ", doc=" + doc + ")");
                fieldExpl.AddDetail(fieldNormExpl);

                fieldExpl.SetMatch(tfExpl.IsMatch());
                fieldExpl.SetValue(tfExpl.GetValue() * idfExpl.GetValue() * fieldNormExpl.GetValue());

                result.AddDetail(fieldExpl);
                System.Boolean?tempAux = fieldExpl.GetMatch();
                result.SetMatch(tempAux);

                // combine them
                result.SetValue(queryExpl.GetValue() * fieldExpl.GetValue());

                if (queryExpl.GetValue() == 1.0f)
                {
                    return(fieldExpl);
                }

                return(result);
            }
			/*(non-Javadoc) <see cref="Lucene.Net.Search.Weight.explain(Lucene.Net.Index.IndexReader, int) */
			public override Explanation Explain(IndexReader reader, int doc)
			{
			    DocValues vals = enclosingInstance.valSrc.GetValues(reader);
			    float sc = queryWeight*vals.FloatVal(doc);

                Explanation result = new ComplexExplanation(true, sc, enclosingInstance.ToString() + ", product of:")
			    ;
                result.AddDetail(vals.Explain(doc));
			    result.AddDetail(new Explanation(enclosingInstance.Boost, "boost"));
			    result.AddDetail(new Explanation(queryNorm, "queryNorm"));
			    return result;
			}
Exemplo n.º 31
0
 internal virtual Explanation DoExplain(AtomicReaderContext info, int doc)
 {
     var subQueryExpl = subQueryWeight.Explain(info, doc);
     if (!subQueryExpl.IsMatch)
     {
         return subQueryExpl;
     }
     // match
     var valSrcExpls = new Explanation[valSrcWeights.Length];
     for (int i = 0; i < valSrcWeights.Length; i++)
     {
         valSrcExpls[i] = valSrcWeights[i].Explain(info, doc);
     }
     Explanation customExp = outerInstance.GetCustomScoreProvider(info)
         .CustomExplain(doc, subQueryExpl, valSrcExpls);
     float sc = outerInstance.Boost * customExp.Value;
     Explanation res = new ComplexExplanation(true, sc, outerInstance.ToString() + ", product of:");
     res.AddDetail(customExp);
     res.AddDetail(new Explanation(outerInstance.Boost, "queryBoost"));
     // actually using the q boost as q weight (== weight value)
     return res;
 }
Exemplo n.º 32
0
			public virtual Explanation Explain(IndexReader reader, int doc)
			{
				
				ComplexExplanation result = new ComplexExplanation();
				result.SetDescription("weight(" + GetQuery() + " in " + doc + "), product of:");
				
				Explanation idfExpl = new Explanation(idf, "idf(docFreq=" + reader.DocFreq(Enclosing_Instance.term) + ", numDocs=" + reader.NumDocs() + ")");
				
				// explain query weight
				Explanation queryExpl = new Explanation();
				queryExpl.SetDescription("queryWeight(" + GetQuery() + "), product of:");
				
				Explanation boostExpl = new Explanation(Enclosing_Instance.GetBoost(), "boost");
				if (Enclosing_Instance.GetBoost() != 1.0f)
					queryExpl.AddDetail(boostExpl);
				queryExpl.AddDetail(idfExpl);
				
				Explanation queryNormExpl = new Explanation(queryNorm, "queryNorm");
				queryExpl.AddDetail(queryNormExpl);
				
				queryExpl.SetValue(boostExpl.GetValue() * idfExpl.GetValue() * queryNormExpl.GetValue());
				
				result.AddDetail(queryExpl);
				
				// explain field weight
				System.String field = Enclosing_Instance.term.Field();
				ComplexExplanation fieldExpl = new ComplexExplanation();
				fieldExpl.SetDescription("fieldWeight(" + Enclosing_Instance.term + " in " + doc + "), product of:");
				
				Explanation tfExpl = Scorer(reader).Explain(doc);
				fieldExpl.AddDetail(tfExpl);
				fieldExpl.AddDetail(idfExpl);
				
				Explanation fieldNormExpl = new Explanation();
				byte[] fieldNorms = reader.Norms(field);
				float fieldNorm = fieldNorms != null ? Similarity.DecodeNorm(fieldNorms[doc]) : 0.0f;
				fieldNormExpl.SetValue(fieldNorm);
				fieldNormExpl.SetDescription("fieldNorm(field=" + field + ", doc=" + doc + ")");
				fieldExpl.AddDetail(fieldNormExpl);
				
				fieldExpl.SetMatch(tfExpl.IsMatch());
				fieldExpl.SetValue(tfExpl.GetValue() * idfExpl.GetValue() * fieldNormExpl.GetValue());
				
				result.AddDetail(fieldExpl);
				System.Boolean tempAux = fieldExpl.GetMatch();
				result.SetMatch(tempAux);
				
				// combine them
				result.SetValue(queryExpl.GetValue() * fieldExpl.GetValue());
				
				if (queryExpl.GetValue() == 1.0f)
					return fieldExpl;
				
				return result;
			}
Exemplo n.º 33
0
            public override Explanation Explain(IndexReader reader, int doc)
            {
                ComplexExplanation result = new ComplexExplanation();
                result.Description = "weight(" + Query + " in " + doc + "), product of:";
                
                Explanation idfExpl = new Explanation(idf, "idf(" + Query + ")");
                
                // explain query weight
                Explanation queryExpl = new Explanation();
                queryExpl.Description = "queryWeight(" + Query + "), product of:";
                
                Explanation boostExpl = new Explanation(Enclosing_Instance.Boost, "boost");
                if (Enclosing_Instance.Boost != 1.0f)
                    queryExpl.AddDetail(boostExpl);
                
                queryExpl.AddDetail(idfExpl);
                
                Explanation queryNormExpl = new Explanation(queryNorm, "queryNorm");
                queryExpl.AddDetail(queryNormExpl);
                
                queryExpl.Value = boostExpl.Value * idfExpl.Value * queryNormExpl.Value;
                
                result.AddDetail(queryExpl);
                
                // explain field weight
                ComplexExplanation fieldExpl = new ComplexExplanation();
                fieldExpl.Description = "fieldWeight(" + Query + " in " + doc + "), product of:";

                PhraseScorer scorer = (PhraseScorer)Scorer(reader, true, false);
                if (scorer == null)
                {
                    return new Explanation(0.0f, "no matching docs");
                }
                Explanation tfExplanation = new Explanation();
                int d = scorer.Advance(doc);
                float phraseFreq = (d == doc) ? scorer.CurrentFreq() : 0.0f;
                tfExplanation.Value = similarity.Tf(phraseFreq);
                tfExplanation.Description = "tf(phraseFreq=" + phraseFreq + ")";
                fieldExpl.AddDetail(tfExplanation);
                fieldExpl.AddDetail(idfExpl);
                
                Explanation fieldNormExpl = new Explanation();
                byte[] fieldNorms = reader.Norms(Enclosing_Instance.field);
                float fieldNorm = fieldNorms != null?Similarity.DecodeNorm(fieldNorms[doc]):1.0f;
                fieldNormExpl.Value = fieldNorm;
                fieldNormExpl.Description = "fieldNorm(field=" + Enclosing_Instance.field + ", doc=" + doc + ")";
                fieldExpl.AddDetail(fieldNormExpl);
                
                fieldExpl.Match = tfExplanation.IsMatch;
                fieldExpl.Value = tfExplanation.Value * idfExpl.Value * fieldNormExpl.Value;
                
                result.AddDetail(fieldExpl);
                System.Boolean? tempAux = fieldExpl.Match;
                result.Match = tempAux;
                
                // combine them
                result.Value = queryExpl.Value * fieldExpl.Value;
                
                if (queryExpl.Value == 1.0f)
                    return fieldExpl;
                
                return result;
            }
Exemplo n.º 34
0
            public virtual Explanation Explain(IndexReader reader, int doc)
            {
                int minShouldMatch = Enclosing_Instance.GetMinimumNumberShouldMatch();
                ComplexExplanation sumExpl = new ComplexExplanation();
                sumExpl.SetDescription("sum of:");
                int coord = 0;
                int maxCoord = 0;
                float sum = 0.0f;
                bool fail = false;
                int shouldMatchCount = 0;
                for (int i = 0; i < weights.Count; i++)
                {
                    BooleanClause c = (BooleanClause) Enclosing_Instance.clauses[i];
                    Weight w = (Weight) weights[i];
                    Explanation e = w.Explain(reader, doc);
                    if (!c.IsProhibited())
                        maxCoord++;
                    if (e.IsMatch())
                    {
                        if (!c.IsProhibited())
                        {
                            sumExpl.AddDetail(e);
                            sum += e.GetValue();
                            coord++;
                        }
                        else
                        {
                            Explanation r = new Explanation(0.0f, "match on prohibited clause (" + c.GetQuery().ToString() + ")");
                            r.AddDetail(e);
                            sumExpl.AddDetail(r);
                            fail = true;
                        }
                        if (c.GetOccur().Equals(Occur.SHOULD))
                            shouldMatchCount++;
                    }
                    else if (c.IsRequired())
                    {
                        Explanation r = new Explanation(0.0f, "no match on required clause (" + c.GetQuery().ToString() + ")");
                        r.AddDetail(e);
                        sumExpl.AddDetail(r);
                        fail = true;
                    }
                }
                if (fail)
                {
                    System.Boolean tempAux = false;
                    sumExpl.SetMatch(tempAux);
                    sumExpl.SetValue(0.0f);
                    sumExpl.SetDescription("Failure to meet condition(s) of required/prohibited clause(s)");
                    return sumExpl;
                }
                else if (shouldMatchCount < minShouldMatch)
                {
                    System.Boolean tempAux2 = false;
                    sumExpl.SetMatch(tempAux2);
                    sumExpl.SetValue(0.0f);
                    sumExpl.SetDescription("Failure to match minimum number " + "of optional clauses: " + minShouldMatch);
                    return sumExpl;
                }

                sumExpl.SetMatch(0 < coord ? true : false);
                sumExpl.SetValue(sum);

                float coordFactor = similarity.Coord(coord, maxCoord);
                if (coordFactor == 1.0f)
                // coord is no-op
                    return sumExpl;
                // eliminate wrapper
                else
                {
                    ComplexExplanation result = new ComplexExplanation(sumExpl.IsMatch(), sum * coordFactor, "product of:");
                    result.AddDetail(sumExpl);
                    result.AddDetail(new Explanation(coordFactor, "coord(" + coord + "/" + maxCoord + ")"));
                    return result;
                }
            }
Exemplo n.º 35
0
			/*(non-Javadoc) @see Lucene.Net.Search.Scorer#explain(int) */
			public override Explanation Explain(int doc)
			{
				float sc = qWeight * vals.FloatVal(doc);
				
				Explanation result = new ComplexExplanation(true, sc, Enclosing_Instance.ToString() + ", product of:");
				
				result.AddDetail(vals.Explain(doc));
				result.AddDetail(new Explanation(Enclosing_Instance.GetBoost(), "boost"));
				result.AddDetail(new Explanation(weight.queryNorm, "queryNorm"));
				return result;
			}
Exemplo n.º 36
0
 public Explanation Explain(int doc)
 {
     var subQueryExpl = weight.qWeight.Explain(readerContext, doc);
     if (!subQueryExpl.IsMatch)
     {
         return subQueryExpl;
     }
     float sc = subQueryExpl.Value * vals.FloatVal(doc);
     Explanation res = new ComplexExplanation(true, sc, outerInstance.ToString() + ", product of:");
     res.AddDetail(subQueryExpl);
     res.AddDetail(vals.Explain(doc));
     return res;
 }
			public override Explanation Explain(IndexReader reader, int doc)
			{
				// explain query weight
				Explanation queryExpl = new ComplexExplanation(true, Value, "MatchAllDocsQuery, product of:");
				if (Enclosing_Instance.Boost != 1.0f)
				{
					queryExpl.AddDetail(new Explanation(Enclosing_Instance.Boost, "boost"));
				}
				queryExpl.AddDetail(new Explanation(queryNorm, "queryNorm"));
				
				return queryExpl;
			}
Exemplo n.º 38
0
			public override Explanation Explain(IndexReader reader, int doc)
			{
				ComplexExplanation result = new ComplexExplanation();
				result.SetDescription("weight(" + GetQuery() + " in " + doc + "), product of:");
				
				Explanation idfExpl = new Explanation(idf, "idf(" + GetQuery() + ")");
				
				// explain query weight
				Explanation queryExpl = new Explanation();
				queryExpl.SetDescription("queryWeight(" + GetQuery() + "), product of:");
				
				Explanation boostExpl = new Explanation(Enclosing_Instance.GetBoost(), "boost");
				if (Enclosing_Instance.GetBoost() != 1.0f)
					queryExpl.AddDetail(boostExpl);
				
				queryExpl.AddDetail(idfExpl);
				
				Explanation queryNormExpl = new Explanation(queryNorm, "queryNorm");
				queryExpl.AddDetail(queryNormExpl);
				
				queryExpl.SetValue(boostExpl.GetValue() * idfExpl.GetValue() * queryNormExpl.GetValue());
				
				result.AddDetail(queryExpl);
				
				// explain field weight
				ComplexExplanation fieldExpl = new ComplexExplanation();
				fieldExpl.SetDescription("fieldWeight(" + GetQuery() + " in " + doc + "), product of:");
				
				Scorer scorer = Scorer(reader, true, false);
				if (scorer == null)
				{
					return new Explanation(0.0f, "no matching docs");
				}
				Explanation tfExpl = scorer.Explain(doc);
				fieldExpl.AddDetail(tfExpl);
				fieldExpl.AddDetail(idfExpl);
				
				Explanation fieldNormExpl = new Explanation();
				byte[] fieldNorms = reader.Norms(Enclosing_Instance.field);
				float fieldNorm = fieldNorms != null?Similarity.DecodeNorm(fieldNorms[doc]):1.0f;
				fieldNormExpl.SetValue(fieldNorm);
				fieldNormExpl.SetDescription("fieldNorm(field=" + Enclosing_Instance.field + ", doc=" + doc + ")");
				fieldExpl.AddDetail(fieldNormExpl);
				
				fieldExpl.SetMatch(tfExpl.IsMatch());
				fieldExpl.SetValue(tfExpl.GetValue() * idfExpl.GetValue() * fieldNormExpl.GetValue());
				
				result.AddDetail(fieldExpl);
				System.Boolean? tempAux = fieldExpl.GetMatch();
				result.SetMatch(tempAux);
				
				// combine them
				result.SetValue(queryExpl.GetValue() * fieldExpl.GetValue());
				
				if (queryExpl.GetValue() == 1.0f)
					return fieldExpl;
				
				return result;
			}
Exemplo n.º 39
0
			public override Explanation Explain(IndexReader reader, int doc)
			{
				
				ConstantScorer cs = new ConstantScorer(enclosingInstance, similarity, reader, this);
				bool exists = cs.docIdSetIterator.Advance(doc) == doc;
				
				ComplexExplanation result = new ComplexExplanation();
				
				if (exists)
				{
					result.SetDescription("ConstantScoreQuery(" + Enclosing_Instance.filter + "), product of:");
					result.SetValue(queryWeight);
					System.Boolean tempAux = true;
					result.SetMatch(tempAux);
					result.AddDetail(new Explanation(Enclosing_Instance.GetBoost(), "boost"));
					result.AddDetail(new Explanation(queryNorm, "queryNorm"));
				}
				else
				{
					result.SetDescription("ConstantScoreQuery(" + Enclosing_Instance.filter + ") doesn't match id " + doc);
					result.SetValue(0);
					System.Boolean tempAux2 = false;
					result.SetMatch(tempAux2);
				}
				return result;
			}
Exemplo n.º 40
0
			public virtual Explanation Explain(IndexReader reader, int doc)
			{
				
				ConstantScorer cs = (ConstantScorer) Scorer(reader);
				bool exists = cs.bits.Get(doc);
				
				ComplexExplanation result = new ComplexExplanation();
				
				if (exists)
				{
					result.SetDescription("ConstantScoreQuery(" + Enclosing_Instance.filter + "), product of:");
					result.SetValue(queryWeight);
					System.Boolean tempAux = true;
					result.SetMatch(tempAux);
					result.AddDetail(new Explanation(Enclosing_Instance.GetBoost(), "boost"));
					result.AddDetail(new Explanation(queryNorm, "queryNorm"));
				}
				else
				{
					result.SetDescription("ConstantScoreQuery(" + Enclosing_Instance.filter + ") doesn't match id " + doc);
					result.SetValue(0);
					System.Boolean tempAux2 = false;
					result.SetMatch(tempAux2);
				}
				return result;
			}
Exemplo n.º 41
0
			public override Explanation Explain(IndexReader reader, int doc)
			{
				
				ComplexExplanation result = new ComplexExplanation();
				result.Description = "weight(" + Query + " in " + doc + "), product of:";
				
				Explanation expl = new Explanation(idf, idfExp.Explain());
				
				// explain query weight
				Explanation queryExpl = new Explanation();
				queryExpl.Description = "queryWeight(" + Query + "), product of:";
				
				Explanation boostExpl = new Explanation(Enclosing_Instance.Boost, "boost");
				if (Enclosing_Instance.Boost != 1.0f)
					queryExpl.AddDetail(boostExpl);
				queryExpl.AddDetail(expl);
				
				Explanation queryNormExpl = new Explanation(queryNorm, "queryNorm");
				queryExpl.AddDetail(queryNormExpl);
				
				queryExpl.Value = boostExpl.Value * expl.Value * queryNormExpl.Value;
				
				result.AddDetail(queryExpl);
				
				// explain field weight
				System.String field = Enclosing_Instance.term.Field;
				ComplexExplanation fieldExpl = new ComplexExplanation();
				fieldExpl.Description = "fieldWeight(" + Enclosing_Instance.term + " in " + doc + "), product of:";

                Explanation tfExplanation = new Explanation();
                int tf = 0;
                TermDocs termDocs = reader.TermDocs(enclosingInstance.term);
                if (termDocs != null)
                {
                    try
                    {
                        if (termDocs.SkipTo(doc) && termDocs.Doc == doc)
                        {
                            tf = termDocs.Freq;
                        }
                    }
                    finally
                    {
                        termDocs.Close();
                    }
                    tfExplanation.Value = similarity.Tf(tf);
                    tfExplanation.Description = "tf(termFreq(" + enclosingInstance.term + ")=" + tf + ")";
                }
                else
                {
                    tfExplanation.Value = 0.0f;
                    tfExplanation.Description = "no matching term";
                }
                fieldExpl.AddDetail(tfExplanation);
				fieldExpl.AddDetail(expl);
				
				Explanation fieldNormExpl = new Explanation();
				byte[] fieldNorms = reader.Norms(field);
				float fieldNorm = fieldNorms != null?Similarity.DecodeNorm(fieldNorms[doc]):1.0f;
				fieldNormExpl.Value = fieldNorm;
				fieldNormExpl.Description = "fieldNorm(field=" + field + ", doc=" + doc + ")";
				fieldExpl.AddDetail(fieldNormExpl);

                fieldExpl.Match = tfExplanation.IsMatch;
                fieldExpl.Value = tfExplanation.Value * expl.Value * fieldNormExpl.Value;
				
				result.AddDetail(fieldExpl);
				System.Boolean? tempAux = fieldExpl.Match;
				result.Match = tempAux;
				
				// combine them
				result.Value = queryExpl.Value * fieldExpl.Value;
				
				if (queryExpl.Value == 1.0f)
					return fieldExpl;
				
				return result;
			}
Exemplo n.º 42
0
            public override Explanation Explain(AtomicReaderContext context, int doc)
            {
                // explain query weight
                Explanation queryExpl = new ComplexExplanation(true, QueryWeight, "MatchAllDocsQuery, product of:");
                if (OuterInstance.Boost != 1.0f)
                {
                    queryExpl.AddDetail(new Explanation(OuterInstance.Boost, "boost"));
                }
                queryExpl.AddDetail(new Explanation(QueryNorm, "queryNorm"));

                return queryExpl;
            }
Exemplo n.º 43
0
 public override Explanation Explain(AtomicReaderContext context, int doc)
 {
     Scorer scorer = Scorer(context, context.AtomicReader.LiveDocs);
     if (scorer != null)
     {
         int newDoc = scorer.Advance(doc);
         if (newDoc == doc)
         {
             float freq = scorer.Freq();
             SimScorer docScorer = Similarity.DoSimScorer(Stats, context);
             ComplexExplanation result = new ComplexExplanation();
             result.Description = "weight(" + Query + " in " + doc + ") [" + Similarity.GetType().Name + "], result of:";
             Explanation scoreExplanation = docScorer.Explain(doc, new Explanation(freq, "termFreq=" + freq));
             result.AddDetail(scoreExplanation);
             result.Value = scoreExplanation.Value;
             result.Match = true;
             return result;
         }
     }
     return new ComplexExplanation(false, 0.0f, "no matching term");
 }
Exemplo n.º 44
0
 public override Explanation Explain(AtomicReaderContext readerContext, int doc)
 {
     Explanation subQueryExpl = qWeight.Explain(readerContext, doc);
     if (!subQueryExpl.IsMatch)
     {
         return subQueryExpl;
     }
     FunctionValues vals = outerInstance.boostVal.GetValues(fcontext, readerContext);
     float sc = subQueryExpl.Value * vals.FloatVal(doc);
     Explanation res = new ComplexExplanation(true, sc, outerInstance.ToString() + ", product of:");
     res.AddDetail(subQueryExpl);
     res.AddDetail(vals.Explain(doc));
     return res;
 }