Class ExpectedReciprocalRank

java.lang.Object
org.opensearch.index.rankeval.ExpectedReciprocalRank
All Implemented Interfaces:
NamedWriteable, Writeable, org.opensearch.core.xcontent.ToXContent, org.opensearch.core.xcontent.ToXContentObject, EvaluationMetric

public class ExpectedReciprocalRank extends Object implements EvaluationMetric
Implementation of the Expected Reciprocal Rank metric described in:

Chapelle, O., Metlzer, D., Zhang, Y., & Grinspan, P. (2009).
Expected reciprocal rank for graded relevance.
Proceeding of the 18th ACM Conference on Information and Knowledge Management - CIKM ’09, 621.
https://doi.org/10.1145/1645953.1646033

  • Field Details

  • Constructor Details

    • ExpectedReciprocalRank

      public ExpectedReciprocalRank(int maxRelevance)
      Parameters:
      maxRelevance - the highest expected relevance in the data
    • ExpectedReciprocalRank

      public ExpectedReciprocalRank(int maxRelevance, @Nullable Integer unknownDocRating, int k)
      Parameters:
      maxRelevance - the maximal relevance judgment in the evaluation dataset
      unknownDocRating - the rating for documents the user hasn't supplied an explicit rating for. Can be null, in which case document is skipped.
      k - the search window size all request use.
  • Method Details

    • writeTo

      public void writeTo(StreamOutput out) throws IOException
      Specified by:
      writeTo in interface Writeable
      Throws:
      IOException
    • getWriteableName

      public String getWriteableName()
      Specified by:
      getWriteableName in interface NamedWriteable
    • getUnknownDocRating

      public Integer getUnknownDocRating()
      get the rating used for unrated documents
    • forcedSearchSize

      public OptionalInt forcedSearchSize()
      Description copied from interface: EvaluationMetric
      Metrics can define a size of the search hits windows they want to retrieve by overwriting this method. The default implementation returns an empty optional.
      Specified by:
      forcedSearchSize in interface EvaluationMetric
      Returns:
      the number of search hits this metrics requests
    • evaluate

      public EvalQueryQuality evaluate(String taskId, SearchHit[] hits, List<RatedDocument> ratedDocs)
      Description copied from interface: EvaluationMetric
      Evaluates a single ranking evaluation case.
      Specified by:
      evaluate in interface EvaluationMetric
      Parameters:
      taskId - an identifier of the query for which the search ranking is evaluated
      hits - the search result hits
      ratedDocs - the documents that contain the document rating for this query case
      Returns:
      an EvalQueryQuality instance that contains the metric score with respect to the provided search hits and ratings
    • fromXContent

      public static ExpectedReciprocalRank fromXContent(org.opensearch.core.xcontent.XContentParser parser)
    • toXContent

      public org.opensearch.core.xcontent.XContentBuilder toXContent(org.opensearch.core.xcontent.XContentBuilder builder, org.opensearch.core.xcontent.ToXContent.Params params) throws IOException
      Specified by:
      toXContent in interface org.opensearch.core.xcontent.ToXContent
      Throws:
      IOException
    • equals

      public final boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public final int hashCode()
      Overrides:
      hashCode in class Object