Module org.elasticsearch.server
Class RankFeaturePhaseRankCoordinatorContext
java.lang.Object
org.elasticsearch.search.rank.context.RankFeaturePhaseRankCoordinatorContext
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 Summary
FieldsModifier and TypeFieldDescriptionprotected final intprotected final intprotected final int -
Constructor Summary
ConstructorsConstructorDescriptionRankFeaturePhaseRankCoordinatorContext(int size, int from, int rankWindowSize) -
Method Summary
Modifier and TypeMethodDescriptionvoidcomputeRankScoresForGlobalResults(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.protected abstract voidcomputeScores(RankFeatureDoc[] featureDocs, ActionListener<float[]> scoreListener) Computes the updated scores for a list of features (i.e.protected RankFeatureDoc[]preprocess(RankFeatureDoc[] originalDocs) Preprocesses the provided documents: sorts them by score descending.rankAndPaginate(RankFeatureDoc[] rankFeatureDocs) Ranks the providedRankFeatureDocarray and paginates the results based on the `from` and `size` parameters.
-
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
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 ofScoreDocresults.- Parameters:
rankSearchResults- a list of rank feature results from each shardrankListener- a rankListener to handle the global ranking result
-
rankAndPaginate
Ranks the providedRankFeatureDocarray 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
-