Class QueryRescorer


  • public abstract class QueryRescorer
    extends Rescorer
    A Rescorer that uses a provided Query to assign scores to the first-pass hits.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private Query query  
    • Constructor Summary

      Constructors 
      Constructor Description
      QueryRescorer​(Query query)
      Sole constructor, passing the 2nd pass query to assign scores to the 1st pass hits.
    • Field Detail

      • query

        private final Query query
    • Constructor Detail

      • QueryRescorer

        public QueryRescorer​(Query query)
        Sole constructor, passing the 2nd pass query to assign scores to the 1st pass hits.
    • Method Detail

      • combine

        protected abstract float combine​(float firstPassScore,
                                         boolean secondPassMatches,
                                         float secondPassScore)
        Implement this in a subclass to combine the first pass and second pass scores. If secondPassMatches is false then the second pass query failed to match a hit from the first pass query, and you should ignore the secondPassScore.
      • rescore

        public TopDocs rescore​(IndexSearcher searcher,
                               TopDocs firstPassTopDocs,
                               int topN)
                        throws java.io.IOException
        Description copied from class: Rescorer
        Rescore an initial first-pass TopDocs.
        Specified by:
        rescore in class Rescorer
        Parameters:
        searcher - IndexSearcher used to produce the first pass topDocs
        firstPassTopDocs - Hits from the first pass search. It's very important that these hits were produced by the provided searcher; otherwise the doc IDs will not match!
        topN - How many re-scored hits to return
        Throws:
        java.io.IOException
      • explain

        public Explanation explain​(IndexSearcher searcher,
                                   Explanation firstPassExplanation,
                                   int docID)
                            throws java.io.IOException
        Description copied from class: Rescorer
        Explains how the score for the specified document was computed.
        Specified by:
        explain in class Rescorer
        Throws:
        java.io.IOException
      • rescore

        public static TopDocs rescore​(IndexSearcher searcher,
                                      TopDocs topDocs,
                                      Query query,
                                      double weight,
                                      int topN)
                               throws java.io.IOException
        Sugar API, calling {#rescore} using a simple linear combination of firstPassScore + weight * secondPassScore
        Throws:
        java.io.IOException