Class RankFeaturePhaseRankCoordinatorContext

java.lang.Object
org.elasticsearch.search.rank.context.RankFeaturePhaseRankCoordinatorContext

public abstract class RankFeaturePhaseRankCoordinatorContext extends Object
RankFeaturePhaseRankCoordinatorContext is a base class that runs on the coordinating node and is responsible for retrieving rank_window_size total results from all shards, rank them, and then produce a final paginated response of [from, from+size] results.
  • Field Details

    • size

      protected final int size
    • from

      protected final int from
    • rankWindowSize

      protected final int rankWindowSize
  • Constructor Details

    • RankFeaturePhaseRankCoordinatorContext

      public RankFeaturePhaseRankCoordinatorContext(int size, int from, int rankWindowSize)
  • Method Details

    • computeScores

      protected abstract void computeScores(RankFeatureDoc[] featureDocs, ActionListener<float[]> scoreListener)
      Computes the updated scores for a list of features (i.e. document-based data). We also pass along an ActionListener that should be called with the new scores, and will continue execution to the next phase
    • preprocess

      protected RankFeatureDoc[] preprocess(RankFeatureDoc[] originalDocs)
      Preprocesses the provided documents: sorts them by score descending.
      Parameters:
      originalDocs - documents to process
    • computeRankScoresForGlobalResults

      public void computeRankScoresForGlobalResults(List<RankFeatureResult> rankSearchResults, ActionListener<RankFeatureDoc[]> rankListener)
      This method is responsible for ranking the global results based on the provided rank feature results from each shard.

      We first start by extracting ordered feature data through a List<RankFeatureDoc> from the provided rankSearchResults, and then compute the updated score for each of the documents. Once all the scores have been computed, we sort the results, perform any pagination needed, and then call the `onFinish` consumer with the final array of ScoreDoc results.

      Parameters:
      rankSearchResults - a list of rank feature results from each shard
      rankListener - a rankListener to handle the global ranking result
    • rankAndPaginate

      public RankFeatureDoc[] rankAndPaginate(RankFeatureDoc[] rankFeatureDocs)
      Ranks the provided RankFeatureDoc array and paginates the results based on the `from` and `size` parameters. Filters out documents that have a relevance score less than min_score.
      Parameters:
      rankFeatureDocs - documents to process