Class RerankResult

java.lang.Object
com.redis.vl.utils.rerank.RerankResult

public class RerankResult extends Object
Result from a reranking operation containing reranked documents and optional scores.

This class encapsulates the output of a reranker, which includes the reordered documents and their relevance scores (if requested).

  • Constructor Details

    • RerankResult

      public RerankResult(List<?> documents, List<Double> scores)
      Create a rerank result with documents and scores.
      Parameters:
      documents - The reranked documents (either List<String> or List<Map<String, Object>>)
      scores - The relevance scores for each document, or null if scores were not requested
      Throws:
      IllegalArgumentException - if documents is null, or if scores is non-null but has a different size than documents
  • Method Details

    • getDocuments

      public List<?> getDocuments()
      Get the reranked documents.
      Returns:
      Immutable list of reranked documents
    • getScores

      public List<Double> getScores()
      Get the relevance scores for each document.
      Returns:
      Immutable list of scores, or null if scores were not requested
    • hasScores

      public boolean hasScores()
      Check if this result includes scores.
      Returns:
      true if scores are included, false otherwise
    • getTopScore

      public double getTopScore()
      Get the highest score from the result.
      Returns:
      The maximum score
      Throws:
      IllegalStateException - if no scores are available or if the score list is empty
    • toString

      public String toString()
      Overrides:
      toString in class Object