Class MaxScoreSumPropagator


  • final class MaxScoreSumPropagator
    extends java.lang.Object
    Utility class to propagate scoring information in BooleanQuery, which compute the score as the sum of the scores of its matching clauses. This helps propagate information about the maximum produced score
    • Field Detail

      • numClauses

        private final int numClauses
      • scorers

        private final Scorer[] scorers
      • sumOfOtherMaxScores

        private final double[] sumOfOtherMaxScores
    • Constructor Detail

      • MaxScoreSumPropagator

        MaxScoreSumPropagator​(java.util.Collection<? extends Scorer> scorerList)
                       throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • computeSumOfComplement

        private static double[] computeSumOfComplement​(float[] v)
        Return an array which, at index i, stores the sum of all entries of v except the one at index i.
      • advanceShallow

        void advanceShallow​(int target)
                     throws java.io.IOException
        Throws:
        java.io.IOException
      • getMaxScore

        float getMaxScore​(int upTo)
                   throws java.io.IOException
        Throws:
        java.io.IOException
      • setMinCompetitiveScore

        void setMinCompetitiveScore​(float minScore)
                             throws java.io.IOException
        Throws:
        java.io.IOException
      • getMinCompetitiveScore

        private float getMinCompetitiveScore​(float minScoreSum,
                                             double sumOfOtherMaxScores)
        Return the minimum score that a Scorer must produce in order for a hit to be competitive.

        The way that boolean queries combine scores of their sub clauses together is by summing up the float scores into a double and finally casting back that double back to a float. This method undoes this operation by taking the float score sum and subtracting the sum of other scores as a double as a first approximation of the minimum score that this clause must have.

      • scoreSumUpperBound

        float scoreSumUpperBound​(double sum)