@Override public Explanation explain(final AtomicReaderContext context, final int doc) throws IOException { final Scorer scorer = scorer(context, context.reader() .getLiveDocs()); if (scorer != null) { final int newDoc = scorer.advance(doc); if (newDoc == doc) { final float freq = scorer.freq(); final SimScorer docScorer = similarity.simScorer(stats, context); final ComplexExplanation result = new ComplexExplanation(); result.setDescription("weight(" + getQuery() + " in " + doc + ") [" + similarity.getClass().getSimpleName() + "], result of:"); final Explanation scoreExplanation = docScorer.explain(doc, new Explanation(freq, "termFreq=" + freq)); result.addDetail(scoreExplanation); result.setValue(scoreExplanation.getValue()); result.setMatch(true); return result; } } return new ComplexExplanation(false, 0.0f, "no matching term"); }
@Override public Explanation explain(final AtomicReaderContext context, final int doc) throws IOException { final Scorer scorer = scorer(context, context.reader() .getLiveDocs()); if (scorer != null) { final int newDoc = scorer.advance(doc); if (newDoc == doc) { final float freq = scorer.freq(); final SimScorer docScorer = sim.simScorer(stats, context); final ComplexExplanation result = new ComplexExplanation(); result.setDescription("weight(" + getQuery() + " in " + doc + ") [" + sim.getClass().getSimpleName() + "], result of:"); final Explanation scoreExplanation = docScorer.explain(doc, new Explanation(freq, "termFreq=" + freq)); result.addDetail(scoreExplanation); result.setValue(scoreExplanation.getValue()); result.setMatch(true); return result; } } return new ComplexExplanation(false, 0.0f, "no matching term"); }
private Explanation doExplain(AtomicReaderContext info, int doc) throws IOException { Explanation subQueryExpl = subQueryWeight.explain(info, 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(info, doc); } Explanation customExp = CustomScoreQuery.this.getCustomScoreProvider(info).customExplain(doc,subQueryExpl,valSrcExpls); float sc = queryWeight * customExp.getValue(); Explanation res = new ComplexExplanation( true, sc, CustomScoreQuery.this.toString() + ", product of:"); res.addDetail(customExp); res.addDetail(new Explanation(queryWeight, "queryWeight")); return res; }
private Explanation explain(int target) throws IOException { int docId; do { docId = nextDocOutOfOrder(); if (docId < target) { int tempDocId = docsEnum.advance(target); if (tempDocId == target) { docId = tempDocId; break; } } else if (docId == target) { break; } docsEnum = null; // goto the next ord. } while (docId != DocIdSetIterator.NO_MORE_DOCS); return new ComplexExplanation(true, scores[ords[scoreUpto]], "Score based on join value " + termsEnum.term().utf8ToString()); }
@Override public Explanation explain(AtomicReaderContext context, int doc) throws IOException { Scorer scorer = scorer(context, context.reader().getLiveDocs()); boolean exists = scorer.advance(doc) == doc; ComplexExplanation result = new ComplexExplanation(); if (exists) { result.setDescription(this.toString() + " , product of:"); result.setValue(queryWeight); result.setMatch(Boolean.TRUE); result.addDetail(new Explanation(getBoost(), "boost")); result.addDetail(new Explanation(queryNorm,"queryNorm")); } else { result.setDescription(this.toString() + " doesn't match id " + doc); result.setValue(0); result.setMatch(Boolean.FALSE); } return result; }
public Explanation explain(int doc) throws IOException { advance(doc); boolean matched = this.doc == doc; this.doc = doc; float sc = matched ? score() : 0; double dist = dist(latVals.doubleVal(doc), lonVals.doubleVal(doc)); String description = SpatialDistanceQuery.this.toString(); Explanation result = new ComplexExplanation (this.doc == doc, sc, description + " product of:"); // result.addDetail(new Explanation((float)dist, "hsin("+latVals.explain(doc)+","+lonVals.explain(doc))); result.addDetail(new Explanation((float)dist, "hsin("+latVals.doubleVal(doc)+","+lonVals.doubleVal(doc))); result.addDetail(new Explanation(getBoost(), "boost")); result.addDetail(new Explanation(weight.queryNorm,"queryNorm")); return result; }
@Override public Explanation explain(AtomicReaderContext context, int doc) throws IOException { // TODO: figure out what this actually is! final Scorer cs = scorer(context, context.reader().getLiveDocs()); final boolean exists = (cs != null && cs.advance(doc) == doc); final ComplexExplanation result = new ComplexExplanation(); if (exists) { result.setDescription(GraphQuery.this.toString() + ", product of:"); result.setValue(queryWeight); result.setMatch(Boolean.TRUE); result.addDetail(new Explanation(getBoost(), "boost")); result.addDetail(new Explanation(queryNorm, "queryNorm")); } else { result.setDescription(GraphQuery.this.toString() + " doesn't match id " + doc); result.setValue(0); result.setMatch(Boolean.FALSE); } return result; }
@Override public Explanation explain(AtomicReaderContext context, int doc) throws IOException { Scorer scorer = scorer(context, true, false, context.reader() .getLiveDocs()); if (scorer != null) { int newDoc = scorer.advance(doc); if (newDoc == doc) { float freq = scorer.freq(); ExactSimScorer docScorer = sim.exactSimScorer(stats, context); ComplexExplanation result = new ComplexExplanation(); result.setDescription("weight(" + getQuery() + " in " + doc + ") [" + sim.getClass().getSimpleName() + "], result of:"); Explanation scoreExplanation = docScorer.explain(doc, new Explanation(freq, "termFreq=" + freq)); result.addDetail(scoreExplanation); result.setValue(scoreExplanation.getValue()); result.setMatch(true); return result; } } return new ComplexExplanation(false, 0.0f, "no matching term"); }
private Explanation doExplain(AtomicReaderContext info, int doc) throws IOException { Explanation subQueryExpl = subQueryWeight.explain(info, 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(info, doc); } Explanation customExp = CustomScoreQuery.this.getCustomScoreProvider(info).customExplain(doc,subQueryExpl,valSrcExpls); float sc = getBoost() * customExp.getValue(); Explanation res = new ComplexExplanation( true, sc, CustomScoreQuery.this.toString() + ", product of:"); res.addDetail(customExp); res.addDetail(new Explanation(getBoost(), "queryBoost")); // actually using the q boost as q weight (== weight value) return res; }
@Override public Explanation explain(AtomicReaderContext context, int doc) throws IOException { Scorer scorer = scorer(context, true, false, context.reader().getLiveDocs()); boolean exists = scorer.advance(doc) == doc; ComplexExplanation result = new ComplexExplanation(); if (exists) { result.setDescription(this.toString() + " , product of:"); result.setValue(queryWeight); result.setMatch(Boolean.TRUE); result.addDetail(new Explanation(getBoost(), "boost")); result.addDetail(new Explanation(queryNorm,"queryNorm")); } else { result.setDescription(this.toString() + " doesn't match id " + doc); result.setValue(0); result.setMatch(Boolean.FALSE); } return result; }
public synchronized List<String> getMatchingFieldNames(int docId) { Set<String> matchingFieldNames = new HashSet<String>(); try { Explanation explanation = getIndexSearcher().explain(luceneQuery, docId); if (explanation instanceof ComplexExplanation) { Explanation[] details = explanation.getDetails(); if (details != null) { for (int i = 0; i < details.length; i++) { Explanation detail = details[i]; matchingFieldNames.addAll(getMatchingFieldNames(docId, detail)); } } } else { matchingFieldNames.addAll(getMatchingFieldNames(docId, explanation)); } } catch (IOException e) { throw new RuntimeException(e); } return new ArrayList<String>(matchingFieldNames); }
@Override public Explanation explain(AtomicReaderContext context, int doc) throws IOException { PayloadNearSpanScorer scorer = (PayloadNearSpanScorer) scorer(context, context.reader().getLiveDocs()); if (scorer != null) { int newDoc = scorer.advance(doc); if (newDoc == doc) { float freq = scorer.freq(); SimScorer docScorer = similarity.simScorer(stats, context); Explanation expl = new Explanation(); expl.setDescription("weight("+getQuery()+" in "+doc+") [" + similarity.getClass().getSimpleName() + "], result of:"); Explanation scoreExplanation = docScorer.explain(doc, new Explanation(freq, "phraseFreq=" + freq)); expl.addDetail(scoreExplanation); expl.setValue(scoreExplanation.getValue()); String field = ((SpanQuery)getQuery()).getField(); // now the payloads part Explanation payloadExpl = function.explain(doc, field, scorer.payloadsSeen, scorer.payloadScore); // combined ComplexExplanation result = new ComplexExplanation(); result.addDetail(expl); result.addDetail(payloadExpl); result.setValue(expl.getValue() * payloadExpl.getValue()); result.setDescription("PayloadNearQuery, product of:"); return result; } } return new ComplexExplanation(false, 0.0f, "no matching term"); }
@Override public Explanation explain(AtomicReaderContext context, int doc) throws IOException { PayloadTermSpanScorer scorer = (PayloadTermSpanScorer) scorer(context, context.reader().getLiveDocs()); if (scorer != null) { int newDoc = scorer.advance(doc); if (newDoc == doc) { float freq = scorer.sloppyFreq(); SimScorer docScorer = similarity.simScorer(stats, context); Explanation expl = new Explanation(); expl.setDescription("weight("+getQuery()+" in "+doc+") [" + similarity.getClass().getSimpleName() + "], result of:"); Explanation scoreExplanation = docScorer.explain(doc, new Explanation(freq, "phraseFreq=" + freq)); expl.addDetail(scoreExplanation); expl.setValue(scoreExplanation.getValue()); // 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)getQuery()).getField(); Explanation payloadExpl = function.explain(doc, field, scorer.payloadsSeen, scorer.payloadScore); payloadExpl.setValue(scorer.getPayloadScore()); // combined ComplexExplanation result = new ComplexExplanation(); if (includeSpanScore) { result.addDetail(expl); result.addDetail(payloadExpl); result.setValue(expl.getValue() * payloadExpl.getValue()); result.setDescription("btq, product of:"); } else { result.addDetail(payloadExpl); result.setValue(payloadExpl.getValue()); result.setDescription("btq(includeSpanScore=false), result of:"); } result.setMatch(true); // LUCENE-1303 return result; } } return new ComplexExplanation(false, 0.0f, "no matching term"); }
public Explanation explain(Similarity similarity, Query query) { if (!isMatched()) return null; ComplexExplanation result = new ComplexExplanation(); result.setDescription("weight("+query+" in "+ doc +") [" + similarity.getClass().getSimpleName() + "], result of:"); Explanation scoreExplanation = docScorer.explain(doc, new Explanation(freq, "termFreq=" + freq)); result.addDetail(scoreExplanation); result.setValue(scoreExplanation.getValue()); result.setMatch(true); return result; }
@Override public Explanation explain(AtomicReaderContext context, int doc) throws IOException { FlexibleScorer scorer = (FlexibleScorer) scorer(context, context.reader().getLiveDocs()); if (scorer != null) { int newDoc = scorer.advance(doc); if (newDoc == doc) { FlexibleScoreModelStrategy strategy = scorer.getStrategy(); strategy.prepare(0, 0, true); return strategy.explain(similarity, query, doc); } } return new ComplexExplanation(false, 0.0f, "no matching term"); }
@Override public Explanation explain(AtomicReaderContext context, int doc) throws IOException { BlockJoinScorer scorer = (BlockJoinScorer) scorer(context, context.reader().getLiveDocs()); if (scorer != null && scorer.advance(doc) == doc) { return scorer.explain(context.docBase); } return new ComplexExplanation(false, 0.0f, "Not a match"); }
public Explanation explain(int docBase) throws IOException { int start = docBase + prevParentDoc + 1; // +1 b/c prevParentDoc is previous parent doc int end = docBase + parentDoc - 1; // -1 b/c parentDoc is parent doc return new ComplexExplanation( true, score(), String.format(Locale.ROOT, "Score based on child doc range from %d to %d", start, end) ); }
@Override public Explanation explain(AtomicReaderContext context, int doc) throws IOException { BlockJoinScorer scorer = (BlockJoinScorer) scorer(context, true, false, context.reader().getLiveDocs()); if (scorer != null) { if (scorer.advance(doc) == doc) { return scorer.explain(context.docBase); } } return new ComplexExplanation(false, 0.0f, "Not a match"); }
@Override public Explanation explain(AtomicReaderContext context, int doc) throws IOException { PayloadNearSpanScorer scorer = (PayloadNearSpanScorer) scorer(context, true, false, context.reader().getLiveDocs()); if (scorer != null) { int newDoc = scorer.advance(doc); if (newDoc == doc) { float freq = scorer.freq(); SloppySimScorer docScorer = similarity.sloppySimScorer(stats, context); Explanation expl = new Explanation(); expl.setDescription("weight("+getQuery()+" in "+doc+") [" + similarity.getClass().getSimpleName() + "], result of:"); Explanation scoreExplanation = docScorer.explain(doc, new Explanation(freq, "phraseFreq=" + freq)); expl.addDetail(scoreExplanation); expl.setValue(scoreExplanation.getValue()); String field = ((SpanQuery)getQuery()).getField(); // now the payloads part Explanation payloadExpl = function.explain(doc, field, scorer.payloadsSeen, scorer.payloadScore); // combined ComplexExplanation result = new ComplexExplanation(); result.addDetail(expl); result.addDetail(payloadExpl); result.setValue(expl.getValue() * payloadExpl.getValue()); result.setDescription("PayloadNearQuery, product of:"); return result; } } return new ComplexExplanation(false, 0.0f, "no matching term"); }
@Override public Explanation explain(AtomicReaderContext context, int doc) throws IOException { PayloadTermSpanScorer scorer = (PayloadTermSpanScorer) scorer(context, true, false, context.reader().getLiveDocs()); if (scorer != null) { int newDoc = scorer.advance(doc); if (newDoc == doc) { float freq = scorer.sloppyFreq(); SloppySimScorer docScorer = similarity.sloppySimScorer(stats, context); Explanation expl = new Explanation(); expl.setDescription("weight("+getQuery()+" in "+doc+") [" + similarity.getClass().getSimpleName() + "], result of:"); Explanation scoreExplanation = docScorer.explain(doc, new Explanation(freq, "phraseFreq=" + freq)); expl.addDetail(scoreExplanation); expl.setValue(scoreExplanation.getValue()); // 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)getQuery()).getField(); Explanation payloadExpl = function.explain(doc, field, scorer.payloadsSeen, scorer.payloadScore); payloadExpl.setValue(scorer.getPayloadScore()); // combined ComplexExplanation result = new ComplexExplanation(); if (includeSpanScore) { result.addDetail(expl); result.addDetail(payloadExpl); result.setValue(expl.getValue() * payloadExpl.getValue()); result.setDescription("btq, product of:"); } else { result.addDetail(payloadExpl); result.setValue(payloadExpl.getValue()); result.setDescription("btq(includeSpanScore=false), result of:"); } result.setMatch(true); // LUCENE-1303 return result; } } return new ComplexExplanation(false, 0.0f, "no matching term"); }
@Override public Explanation explain(AtomicReaderContext context, int doc) throws IOException { BlockJoinScorer scorer = (BlockJoinScorer) scorer(context, true, false, context.reader().getLiveDocs()); if (scorer != null && scorer.advance(doc) == doc) { return scorer.explain(context.docBase); } return new ComplexExplanation(false, 0.0f, "Not a match"); }
@Override public Explanation explain(AtomicReaderContext context, int doc) throws IOException { PayloadNearSpanScorer scorer = (PayloadNearSpanScorer) scorer(context, true, false, context.reader().getLiveDocs()); if (scorer != null) { int newDoc = scorer.advance(doc); if (newDoc == doc) { float freq = scorer.freq(); SimScorer docScorer = similarity.simScorer(stats, context); Explanation expl = new Explanation(); expl.setDescription("weight("+getQuery()+" in "+doc+") [" + similarity.getClass().getSimpleName() + "], result of:"); Explanation scoreExplanation = docScorer.explain(doc, new Explanation(freq, "phraseFreq=" + freq)); expl.addDetail(scoreExplanation); expl.setValue(scoreExplanation.getValue()); String field = ((SpanQuery)getQuery()).getField(); // now the payloads part Explanation payloadExpl = function.explain(doc, field, scorer.payloadsSeen, scorer.payloadScore); // combined ComplexExplanation result = new ComplexExplanation(); result.addDetail(expl); result.addDetail(payloadExpl); result.setValue(expl.getValue() * payloadExpl.getValue()); result.setDescription("PayloadNearQuery, product of:"); return result; } } return new ComplexExplanation(false, 0.0f, "no matching term"); }