public interface GreedyRerankStrategy
Interface for classes that select the next item to recommend from a list of candidate items. This class is used in
GreedyRerankingItemRecommender to define the greedy strategy for selecting the next item. Often this will be a search for the best item that satisfies some constraint or the best item by some metric that takes in account what items have already been recommended.
@Nullable Result nextItem(long userId, int n, java.util.List<? extends Result> items, java.util.List<? extends Result> candidates)
A method to select the next item to be recommended. This method will be called many times in the process of generating recommendations. Therefore this method should consider optimzation options such as only searching a constant number of the candidates list before picking an item.
userId- the id of the user receiving these recommendation.
n- the total number of items that will be recommended.
items- The list of items already chosen to be recommended in recommendation order
candidates- A ranked list of all items in the system that can still be recommended in this context. Given in ranking order (which is not strictly guaranteed to be in score order, but often will be).
Resultobject noting which candidate item should be added to the recommendation list. The object returned will be directly added to the result list, therefore implementations should use a custom Result subclass if there is any interesting information about the recommendation process to be returned. Alternatively, this method can return a null to indicate that there is no item that can be added to the list without violating a constraint and that the recommendation list should be prematurely terminated.