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); }
public override Explanation Explain(AtomicReaderContext context, int doc) { PayloadNearSpanScorer scorer = (PayloadNearSpanScorer)GetScorer(context, (context.AtomicReader).LiveDocs); if (scorer != null) { int newDoc = scorer.Advance(doc); if (newDoc == doc) { float freq = scorer.Freq; Similarity.SimScorer docScorer = m_similarity.GetSimScorer(m_stats, context); Explanation expl = new Explanation(); expl.Description = "weight(" + Query + " in " + doc + ") [" + m_similarity.GetType().Name + "], result of:"; Explanation scoreExplanation = docScorer.Explain(doc, new Explanation(freq, "phraseFreq=" + freq)); expl.AddDetail(scoreExplanation); expl.Value = scoreExplanation.Value; string field = ((SpanQuery)Query).Field; // now the payloads part Explanation payloadExpl = outerInstance.m_function.Explain(doc, field, scorer.payloadsSeen, scorer.m_payloadScore); // combined ComplexExplanation result = new ComplexExplanation(); result.AddDetail(expl); result.AddDetail(payloadExpl); result.Value = expl.Value * payloadExpl.Value; result.Description = "PayloadNearQuery, product of:"; return(result); } } return(new ComplexExplanation(false, 0.0f, "no matching term")); }
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); }
private Explanation DoExplain(IndexReader reader, int doc) { Scorer[] valSrcScorers = new Scorer[valSrcWeights.Length]; for (int i = 0; i < valSrcScorers.Length; i++) { valSrcScorers[i] = valSrcWeights[i].Scorer(reader, true, false); } Explanation subQueryExpl = subQueryWeight.Explain(reader, doc); if (!subQueryExpl.IsMatch()) { return(subQueryExpl); } // match Explanation[] valSrcExpls = new Explanation[valSrcScorers.Length]; for (int i = 0; i < valSrcScorers.Length; i++) { valSrcExpls[i] = valSrcScorers[i].Explain(doc); } Explanation customExp = Enclosing_Instance.GetCustomScoreProvider(reader).CustomExplain(doc, subQueryExpl, valSrcExpls); float sc = GetValue() * customExp.GetValue(); Explanation res = new ComplexExplanation(true, sc, Enclosing_Instance.ToString() + ", product of:"); res.AddDetail(customExp); res.AddDetail(new Explanation(GetValue(), "queryBoost")); // actually using the q boost as q weight (== weight value) return(res); }
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(Boost, "boost")); result.AddDetail(new Explanation(weight.queryNorm, "queryNorm")); return(result); }
/*(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); }
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); }
/*(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); }
public Explanation Explain(int doc) { var subQueryExpl = weight.qWeight.Explain(readerContext, doc); if (!subQueryExpl.IsMatch) { return(subQueryExpl); } float sc = subQueryExpl.Value * vals.SingleVal(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(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.SingleVal(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(AtomicReaderContext context, int doc) { PayloadTermSpanScorer scorer = (PayloadTermSpanScorer)Scorer(context, (context.AtomicReader).LiveDocs); if (scorer != null) { int newDoc = scorer.Advance(doc); if (newDoc == doc) { float freq = scorer.SloppyFreq(); Similarity.SimScorer docScorer = Similarity.DoSimScorer(Stats, context); Explanation expl = new Explanation(); expl.Description = "weight(" + Query + " in " + doc + ") [" + Similarity.GetType().Name + "], result of:"; Explanation scoreExplanation = docScorer.Explain(doc, new Explanation(freq, "phraseFreq=" + freq)); expl.AddDetail(scoreExplanation); expl.Value = scoreExplanation.Value; // now the payloads part // QUESTION: Is there a way to avoid this skipTo call? We need to know // whether to load the payload or not // GSI: I suppose we could toString the payload, but I don't think that // would be a good idea string field = ((SpanQuery)Query).Field; Explanation payloadExpl = OuterInstance.Function.Explain(doc, field, scorer.PayloadsSeen, scorer.PayloadScore_Renamed); payloadExpl.Value = scorer.PayloadScore; // combined ComplexExplanation result = new ComplexExplanation(); if (OuterInstance.IncludeSpanScore) { result.AddDetail(expl); result.AddDetail(payloadExpl); result.Value = expl.Value * payloadExpl.Value; result.Description = "btq, product of:"; } else { result.AddDetail(payloadExpl); result.Value = payloadExpl.Value; result.Description = "btq(includeSpanScore=false), result of:"; } result.Match = true; // LUCENE-1303 return(result); } } return(new ComplexExplanation(false, 0.0f, "no matching term")); }
public override Lucene.Net.Search.Explanation Explain(IndexReader reader, int doc, IState state) { var result = new ComplexExplanation { Description = _parent.ToString(), Value = _queryWeight }; result.AddDetail(new Lucene.Net.Search.Explanation(_queryWeight, "queryWeight")); return(result); }
// TODO: remove in 3.0 /*(non-Javadoc) @see Lucene.Net.Search.Scorer#explain(int) */ public override Explanation Explain(int doc) { Explanation subQueryExpl = weight.subQueryWeight.Explain(reader, doc); if (!subQueryExpl.IsMatch()) { return(subQueryExpl); } // match Explanation[] valSrcExpls = new Explanation[valSrcScorers.Length]; for (int i = 0; i < valSrcScorers.Length; i++) { valSrcExpls[i] = valSrcScorers[i].Explain(doc); } Explanation customExp = Enclosing_Instance.CustomExplain(doc, subQueryExpl, valSrcExpls); float sc = qWeight * customExp.GetValue(); Explanation res = new ComplexExplanation(true, sc, Enclosing_Instance.ToString() + ", product of:"); res.AddDetail(customExp); res.AddDetail(new Explanation(qWeight, "queryBoost")); // actually using the q boost as q weight (== weight value) return(res); }
protected internal override Explanation Explain(int doc) { ComplexExplanation result = new ComplexExplanation(); Explanation nonPayloadExpl = base.Explain(doc); result.AddDetail(nonPayloadExpl); // QUESTION: Is there a way to avoid this skipTo call? We need to know // whether to load the payload or not Explanation payloadBoost = new Explanation(); result.AddDetail(payloadBoost); float payloadScore = GetPayloadScore(); payloadBoost.Value = payloadScore; // GSI: I suppose we could toString the payload, but I don't think that // would be a good idea payloadBoost.Description = "scorePayload(...)"; result.Value = nonPayloadExpl.Value * payloadScore; result.Description = "btq, product of:"; result.Match = nonPayloadExpl.Value == 0?false:true; // LUCENE-1303 return(result); }
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 = outerInstance.slop == 0 ? scorer.Freq : ((SloppyPhraseScorer)scorer).SloppyFreq; 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, "phraseFreq=" + freq)); result.AddDetail(scoreExplanation); result.Value = scoreExplanation.Value; result.Match = true; return result; } } return new ComplexExplanation(false, 0.0f, "no matching term"); }
public override Explanation Explain(AtomicReaderContext context, int doc) { SpanScorer scorer = (SpanScorer)Scorer(context, context.AtomicReader.LiveDocs); if (scorer != null) { int newDoc = scorer.Advance(doc); if (newDoc == doc) { float freq = scorer.SloppyFreq(); Similarity.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")); }
public override Explanation Explain(IndexReader reader, int doc) { ComplexExplanation result = new ComplexExplanation(); result.Description = "weight(" + Query + " in " + doc + "), product of:"; 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); bool?tempAux = fieldExpl.Match; result.Match = tempAux; // combine them result.Value = queryExpl.Value * fieldExpl.Value; if (queryExpl.Value == 1.0f) { return(fieldExpl); } return(result); }
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); }
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; using (IEnumerator <BooleanClause> cIter = outerInstance.clauses.GetEnumerator()) { foreach (Weight w in m_weights) { cIter.MoveNext(); BooleanClause c = cIter.Current; if (w.GetScorer(context, context.AtomicReader.LiveDocs) == null) { if (c.IsRequired) { 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.IsProhibited) { 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.IsRequired) { 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, m_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 + "/" + m_maxCoord + ")")); return(result); } }
public override Explanation Explain(AtomicReaderContext context, int doc) { PayloadNearSpanScorer scorer = (PayloadNearSpanScorer)Scorer(context, (context.AtomicReader).LiveDocs); if (scorer != null) { int newDoc = scorer.Advance(doc); if (newDoc == doc) { float freq = scorer.Freq(); Similarity.SimScorer docScorer = Similarity.DoSimScorer(Stats, context); Explanation expl = new Explanation(); expl.Description = "weight(" + Query + " in " + doc + ") [" + Similarity.GetType().Name + "], result of:"; Explanation scoreExplanation = docScorer.Explain(doc, new Explanation(freq, "phraseFreq=" + freq)); expl.AddDetail(scoreExplanation); expl.Value = scoreExplanation.Value; string field = ((SpanQuery)Query).Field; // now the payloads part Explanation payloadExpl = OuterInstance.Function.Explain(doc, field, scorer.PayloadsSeen, scorer.PayloadScore); // combined ComplexExplanation result = new ComplexExplanation(); result.AddDetail(expl); result.AddDetail(payloadExpl); result.Value = expl.Value * payloadExpl.Value; result.Description = "PayloadNearQuery, product of:"; return result; } } return new ComplexExplanation(false, 0.0f, "no matching term"); }
protected internal override Explanation Explain(int doc) { ComplexExplanation result = new ComplexExplanation(); Explanation nonPayloadExpl = base.Explain(doc); result.AddDetail(nonPayloadExpl); // QUESTION: Is there a way to avoid this skipTo call? We need to know // whether to load the payload or not Explanation payloadBoost = new Explanation(); result.AddDetail(payloadBoost); float payloadScore = GetPayloadScore(); payloadBoost.Value = payloadScore; // GSI: I suppose we could toString the payload, but I don't think that // would be a good idea payloadBoost.Description = "scorePayload(...)"; result.Value = nonPayloadExpl.Value * payloadScore; result.Description = "btq, product of:"; result.Match = nonPayloadExpl.Value == 0?false:true; // LUCENE-1303 return result; }
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); }
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; }
public override Explanation Explain(AtomicReaderContext context, int doc) { PayloadTermSpanScorer scorer = (PayloadTermSpanScorer)Scorer(context, (context.AtomicReader).LiveDocs); if (scorer != null) { int newDoc = scorer.Advance(doc); if (newDoc == doc) { float freq = scorer.SloppyFreq(); Similarity.SimScorer docScorer = Similarity.DoSimScorer(Stats, context); Explanation expl = new Explanation(); expl.Description = "weight(" + Query + " in " + doc + ") [" + Similarity.GetType().Name + "], result of:"; Explanation scoreExplanation = docScorer.Explain(doc, new Explanation(freq, "phraseFreq=" + freq)); expl.AddDetail(scoreExplanation); expl.Value = scoreExplanation.Value; // now the payloads part // QUESTION: Is there a way to avoid this skipTo call? We need to know // whether to load the payload or not // GSI: I suppose we could toString the payload, but I don't think that // would be a good idea string field = ((SpanQuery)Query).Field; Explanation payloadExpl = OuterInstance.Function.Explain(doc, field, scorer.PayloadsSeen, scorer.PayloadScore_Renamed); payloadExpl.Value = scorer.PayloadScore; // combined ComplexExplanation result = new ComplexExplanation(); if (OuterInstance.IncludeSpanScore) { result.AddDetail(expl); result.AddDetail(payloadExpl); result.Value = expl.Value * payloadExpl.Value; result.Description = "btq, product of:"; } else { result.AddDetail(payloadExpl); result.Value = payloadExpl.Value; result.Description = "btq(includeSpanScore=false), result of:"; } result.Match = true; // LUCENE-1303 return result; } } return new ComplexExplanation(false, 0.0f, "no matching term"); }
/*(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; }
private Explanation DoExplain(IndexReader reader, int doc) { Explanation subQueryExpl = subQueryWeight.Explain(reader, doc); if (!subQueryExpl.IsMatch) { return subQueryExpl; } // match Explanation[] valSrcExpls = new Explanation[valSrcWeights.Length]; for (int i = 0; i < valSrcWeights.Length; i++) { valSrcExpls[i] = valSrcWeights[i].Explain(reader, doc); } Explanation customExp = Enclosing_Instance.GetCustomScoreProvider(reader).CustomExplain(doc, subQueryExpl, valSrcExpls); float sc = Value * customExp.Value; Explanation res = new ComplexExplanation(true, sc, Enclosing_Instance.ToString() + ", product of:"); res.AddDetail(customExp); res.AddDetail(new Explanation(Value, "queryBoost")); // actually using the q boost as q weight (== weight value) return res; }