/** Explain the score we computed for doc */ @Override public Explanation explain(LeafReaderContext context, int doc) throws IOException { boolean match = false; float max = Float.NEGATIVE_INFINITY, sum = 0.0f; List<Explanation> subs = new ArrayList<>(); for (Weight wt : weights) { Explanation e = wt.explain(context, doc); if (e.isMatch()) { match = true; subs.add(e); sum += e.getValue(); max = Math.max(max, e.getValue()); } } if (match) { final float score = max + (sum - max) * tieBreakerMultiplier; final String desc = tieBreakerMultiplier == 0.0f ? "max of:" : "max plus " + tieBreakerMultiplier + " times others of:"; return Explanation.match(score, desc, subs); } else { return Explanation.noMatch("No matching clause"); } }
@Override public Explanation explain(IndexSearcher searcher, Explanation firstPassExplanation, int docID) throws IOException { Explanation secondPassExplanation = searcher.explain(query, docID); Float secondPassScore = secondPassExplanation.isMatch() ? secondPassExplanation.getValue() : null; float score; if (secondPassScore == null) { score = combine(firstPassExplanation.getValue(), false, 0.0f); } else { score = combine(firstPassExplanation.getValue(), true, secondPassScore.floatValue()); } Explanation first = Explanation.match(firstPassExplanation.getValue(), "first pass score", firstPassExplanation); Explanation second; if (secondPassScore == null) { second = Explanation.noMatch("no second pass score"); } else { second = Explanation.match(secondPassScore, "second pass score", secondPassExplanation); } return Explanation.match(score, "combined first and second pass score using " + getClass(), first, second); }
BooleanClause c = cIter.next(); Explanation e = w.explain(context, doc); if (e.isMatch()) { if (c.isScoring()) { subs.add(e);
public boolean isMatch() { return explanation != null && explanation.isMatch(); }
public static void writeExplanation(StreamOutput out, Explanation explanation) throws IOException { out.writeBoolean(explanation.isMatch()); out.writeString(explanation.getDescription()); Explanation[] subExplanations = explanation.getDetails(); out.writeVInt(subExplanations.length); for (Explanation subExp : subExplanations) { writeExplanation(out, subExp); } if (explanation.isMatch()) { out.writeFloat(explanation.getValue()); } }
if (!expl.isMatch()) { return expl;
for (String field: fields){ Query query = new WildcardQuery(new Term(field, "*alue1")); Explanation ex = searcher.explain(query, docID); if (ex.isMatch()){ //Your query matched field } }
float primaryWeight = rescore.queryWeight(); Explanation prim; if (sourceExplanation.isMatch()) { prim = Explanation.match( sourceExplanation.getValue() * primaryWeight, if (rescoreExplain != null && rescoreExplain.isMatch()) { float secondaryWeight = rescore.rescoreQueryWeight(); Explanation sec = Explanation.match(
@Override public Explanation explain(LeafReaderContext ctx, int docId, Explanation scoreExplanation) throws IOException { if (scoreExplanation.isMatch() == false) { return scoreExplanation; } Explanation boostExpl = boost.explain(ctx, docId, scoreExplanation); if (boostExpl.isMatch() == false) { return scoreExplanation; } return Explanation.match(scoreExplanation.getValue() * boostExpl.getValue(), "product of:", scoreExplanation, boostExpl); }
@Override public Explanation explain(LeafReaderContext context, int doc) throws IOException { final Explanation matchExplanation = matchWeight.explain(context, doc); final Explanation contextExplanation = contextWeight.explain(context, doc); if (matchExplanation.isMatch() == false || contextExplanation.isMatch() == false) { return matchExplanation; } return Explanation.match(matchExplanation.getValue() * contextBoost, "product of:", matchExplanation, Explanation.match(contextBoost, "boost")); }
@Override public Explanation explain(LeafReaderContext context, int doc) throws IOException { final Explanation matchExplanation = matchWeight.explain(context, doc); final Explanation contextExplanation = contextWeight.explain(context, doc); if (matchExplanation.isMatch() == false || contextExplanation.isMatch() == false) { return matchExplanation; } return Explanation.match(matchExplanation.getValue() * boost, "product of:", matchExplanation, Explanation.match(boost, "boost")); }
@Override public Explanation explain(LeafReaderContext ctx, int docId, Explanation scoreExplanation) throws IOException { Explanation inner = query.explain(ctx, docId, scoreExplanation); if (inner.isMatch() == false) { return inner; } return Explanation.match(boost, "Matched boosting query " + query.toString()); } }
public static void writeExplanation(StreamOutput out, Explanation explanation) throws IOException { out.writeBoolean(explanation.isMatch()); out.writeString(explanation.getDescription()); Explanation[] subExplanations = explanation.getDetails(); out.writeVInt(subExplanations.length); for (Explanation subExp : subExplanations) { writeExplanation(out, subExp); } if (explanation.isMatch()) { out.writeFloat(explanation.getValue()); } }
public static void writeExplanation(StreamOutput out, Explanation explanation) throws IOException { out.writeBoolean(explanation.isMatch()); out.writeString(explanation.getDescription()); Explanation[] subExplanations = explanation.getDetails(); out.writeVInt(subExplanations.length); for (Explanation subExp : subExplanations) { writeExplanation(out, subExp); } if (explanation.isMatch()) { out.writeFloat(explanation.getValue()); } }
public static void writeExplanation(StreamOutput out, Explanation explanation) throws IOException { out.writeBoolean(explanation.isMatch()); out.writeString(explanation.getDescription()); Explanation[] subExplanations = explanation.getDetails(); out.writeVInt(subExplanations.length); for (Explanation subExp : subExplanations) { writeExplanation(out, subExp); } if (explanation.isMatch()) { out.writeFloat(explanation.getValue()); } }
public static void writeExplanation(StreamOutput out, Explanation explanation) throws IOException { out.writeBoolean(explanation.isMatch()); out.writeString(explanation.getDescription()); Explanation[] subExplanations = explanation.getDetails(); out.writeVInt(subExplanations.length); for (Explanation subExp : subExplanations) { writeExplanation(out, subExp); } if (explanation.isMatch()) { out.writeFloat(explanation.getValue()); } }
public Explanation explain(int doc) throws IOException { Explanation subQueryExpl = weight.qWeight.explain(readerContext ,doc); if (!subQueryExpl.isMatch()) { return subQueryExpl; } float sc = subQueryExpl.getValue() * vals.floatVal(doc); return Explanation.match(sc, BoostedQuery.this.toString() + ", product of:", subQueryExpl, vals.explain(doc)); }
public Explanation explain(int doc) throws IOException { Explanation subQueryExpl = weight.qWeight.explain(readerContext ,doc); if (!subQueryExpl.isMatch()) { return subQueryExpl; } float sc = subQueryExpl.getValue() * vals.floatVal(doc); return Explanation.match(sc, BoostedQuery.this.toString() + ", product of:", subQueryExpl, vals.explain(doc)); }
@Override public void doMatchQuery(String queryId, Query matchQuery, Map<String, String> metadata) throws IOException { int maxDocs = docs.getIndexReader().maxDoc(); for (int i = 0; i < maxDocs; i++) { Explanation explanation = docs.getSearcher().explain(matchQuery, i); if (explanation.isMatch()) addMatch(new ExplainingMatch(queryId, docs.resolveDocId(i), explanation)); } }
@Override public Explanation explain(LeafReaderContext readerContext, int doc) throws IOException { Explanation subQueryExpl = qWeight.explain(readerContext,doc); if (!subQueryExpl.isMatch()) { return subQueryExpl; } FunctionValues vals = boostVal.getValues(fcontext, readerContext); float sc = subQueryExpl.getValue() * vals.floatVal(doc); return Explanation.match(sc, BoostedQuery.this.toString() + ", product of:", subQueryExpl, vals.explain(doc)); } }