@Override
    public Explanation explain(LeafReaderContext context, int doc) throws IOException {

      Explanation expl = subQueryWeight.explain(context, doc);
      if (!expl.isMatch()) {
        return expl;
      }
      // First: Gather explanations for all filters
      List<Explanation> filterExplanations = new ArrayList<>();
      for (int i = 0; i < filterFunctions.length; ++i) {
        Bits docSet =
            Lucene.asSequentialAccessBits(
                context.reader().maxDoc(), filterWeights[i].scorer(context));
        if (docSet.get(doc)) {
          FilterFunction filterFunction = filterFunctions[i];
          Explanation functionExplanation =
              filterFunction.function.getLeafScoreFunction(context).explainScore(doc, expl);
          double factor = functionExplanation.getValue();
          float sc = CombineFunction.toFloat(factor);
          Explanation filterExplanation =
              Explanation.match(
                  sc,
                  "function score, product of:",
                  Explanation.match(1.0f, "match filter: " + filterFunction.filter.toString()),
                  functionExplanation);
          filterExplanations.add(filterExplanation);
        }
      }
      if (filterExplanations.size() > 0) {
        FiltersFunctionFactorScorer scorer = functionScorer(context);
        int actualDoc = scorer.iterator().advance(doc);
        assert (actualDoc == doc);
        double score = scorer.computeScore(doc, expl.getValue());
        Explanation factorExplanation =
            Explanation.match(
                CombineFunction.toFloat(score),
                "function score, score mode ["
                    + scoreMode.toString().toLowerCase(Locale.ROOT)
                    + "]",
                filterExplanations);
        expl = combineFunction.explain(expl, factorExplanation, maxBoost);
      }
      if (minScore != null && minScore > expl.getValue()) {
        expl =
            Explanation.noMatch(
                "Score value is too low, expected at least "
                    + minScore
                    + " but got "
                    + expl.getValue(),
                expl);
      }
      return expl;
    }
 public Explanation explain(AtomicReaderContext context, int doc) throws IOException {
   Explanation mainExplain = mainWeight.explain(context, doc);
   return new QueryRescorer(reRankQuery) {
     @Override
     protected float combine(
         float firstPassScore, boolean secondPassMatches, float secondPassScore) {
       float score = firstPassScore;
       if (secondPassMatches) {
         score += reRankWeight * secondPassScore;
       }
       return score;
     }
   }.explain(searcher, mainExplain, context.docBase + doc);
 }
    @Override
    public Explanation explain(IndexReader reader, int doc) throws IOException {
      SolrIndexReader topReader = (SolrIndexReader) reader;
      SolrIndexReader[] subReaders = topReader.getLeafReaders();
      int[] offsets = topReader.getLeafOffsets();
      int readerPos = SolrIndexReader.readerIndex(doc, offsets);
      int readerBase = offsets[readerPos];

      Explanation subQueryExpl = qWeight.explain(reader, doc);
      if (!subQueryExpl.isMatch()) {
        return subQueryExpl;
      }

      DocValues vals = boostVal.getValues(context, subReaders[readerPos]);
      float sc = subQueryExpl.getValue() * vals.floatVal(doc - readerBase);
      Explanation res =
          new ComplexExplanation(true, sc, BoostedQuery.this.toString() + ", product of:");
      res.addDetail(subQueryExpl);
      res.addDetail(vals.explain(doc - readerBase));
      return res;
    }
 private Explanation doExplain(IndexReader reader, int doc) throws IOException {
   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 =
       CustomScoreQuery.this
           .getCustomScoreProvider(reader)
           .customExplain(doc, subQueryExpl, valSrcExpls);
   float sc = getValue() * customExp.getValue();
   Explanation res =
       new ComplexExplanation(true, sc, CustomScoreQuery.this.toString() + ", product of:");
   res.addDetail(customExp);
   res.addDetail(
       new Explanation(
           getValue(),
           "queryBoost")); // actually using the q boost as q weight (== weight value)
   return res;
 }
Esempio n. 5
0
 @Override
 public Explanation explain(final AtomicReaderContext context, final int doc)
     throws IOException {
   return weight.explain(context, doc);
 }
 @Override
 public Explanation explain(LeafReaderContext context, int doc) throws IOException {
   shardKeyMap.add(context.reader());
   return in.explain(context, doc);
 }