Rescorer (Lucene 10.5.0 core API)
Description: declaration: package: org.apache.lucene.search, class: Rescorer

Package org.apache.lucene.search

# Class Rescorer

java.lang.Object
org.apache.lucene.search.Rescorer

Direct Known Subclasses:
  `DoubleValuesSourceRescorer`, `QueryRescorer`, `SortRescorer`

public abstract class Rescorer extends Object
Re-scores the topN results (`TopDocs`) from an original query. See `QueryRescorer` for an actual implementation. Typically, you run a low-cost first-pass query across the entire index, collecting the top few hundred hits perhaps, and then use this class to mix in a more costly second pass scoring.

See `QueryRescorer.rescore(IndexSearcher,TopDocs,Query,double,int)` for a simple static method to call to rescore using a 2nd pass `Query`.

WARNING: This API is experimental and might change in incompatible ways in the next release.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Rescorer()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `abstract Explanation`
  `explain(IndexSearcher searcher, Explanation firstPassExplanation, int docID)`
  Explains how the score for the specified document was computed.
  `abstract TopDocs`
  `rescore(IndexSearcher searcher, TopDocs firstPassTopDocs, int topN)`
  Rescore an initial first-pass `TopDocs`.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### Rescorer

    public Rescorer()

- ## Method Details

  - ### rescore

    public abstract TopDocs rescore(IndexSearcher searcher, TopDocs firstPassTopDocs, int topN) throws IOException
    Rescore an initial first-pass `TopDocs`.
    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:
      `IOException`

  - ### explain

    public abstract Explanation explain(IndexSearcher searcher, Explanation firstPassExplanation, int docID) throws IOException
    Explains how the score for the specified document was computed.
    Throws:
      `IOException`