Class MeanReciprocalRank

java.lang.Object
org.elasticsearch.index.rankeval.MeanReciprocalRank
All Implemented Interfaces:
org.elasticsearch.common.io.stream.NamedWriteable, org.elasticsearch.common.io.stream.Writeable, org.elasticsearch.common.xcontent.ToXContent, org.elasticsearch.common.xcontent.ToXContentObject, EvaluationMetric

public class MeanReciprocalRank extends Object implements EvaluationMetric
Metric implementing Mean Reciprocal Rank (https://en.wikipedia.org/wiki/Mean_reciprocal_rank).
By default documents with a rating equal or bigger than 1 are considered to be "relevant" for the reciprocal rank calculation. This value can be changes using the relevant_rating_threshold` parameter.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
     

    Nested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.ToXContent

    org.elasticsearch.common.xcontent.ToXContent.DelegatingMapParams, org.elasticsearch.common.xcontent.ToXContent.MapParams, org.elasticsearch.common.xcontent.ToXContent.Params

    Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable

    org.elasticsearch.common.io.stream.Writeable.Reader<V extends Object>, org.elasticsearch.common.io.stream.Writeable.Writer<V extends Object>
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static String
     

    Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent

    EMPTY_PARAMS
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    MeanReciprocalRank​(int relevantRatingThreshold, int k)
    Metric implementing Mean Reciprocal Rank (https://en.wikipedia.org/wiki/Mean_reciprocal_rank).
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    equals​(Object obj)
     
    evaluate​(String taskId, org.elasticsearch.search.SearchHit[] hits, List<RatedDocument> ratedDocs)
    Compute ReciprocalRank based on provided relevant document IDs.
    Metrics can define a size of the search hits windows they want to retrieve by overwriting this method.
    fromXContent​(org.elasticsearch.common.xcontent.XContentParser parser)
     
    int
    Return the rating threshold above which ratings are considered to be "relevant".
     
    int
     
    org.elasticsearch.common.xcontent.XContentBuilder
    toXContent​(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)
     
    void
    writeTo​(org.elasticsearch.common.io.stream.StreamOutput out)
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.elasticsearch.index.rankeval.EvaluationMetric

    combine

    Methods inherited from interface org.elasticsearch.common.xcontent.ToXContentObject

    isFragment
  • Field Details

  • Constructor Details

    • MeanReciprocalRank

      public MeanReciprocalRank()
    • MeanReciprocalRank

      public MeanReciprocalRank(int relevantRatingThreshold, int k)
      Metric implementing Mean Reciprocal Rank (https://en.wikipedia.org/wiki/Mean_reciprocal_rank).
      Parameters:
      relevantRatingThreshold - the rating value that a document needs to be regarded as "relevant". Defaults to 1.
      k - the search window size all request use.
  • Method Details

    • writeTo

      public void writeTo(org.elasticsearch.common.io.stream.StreamOutput out) throws IOException
      Specified by:
      writeTo in interface org.elasticsearch.common.io.stream.Writeable
      Throws:
      IOException
    • 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
    • getWriteableName

      public String getWriteableName()
      Specified by:
      getWriteableName in interface org.elasticsearch.common.io.stream.NamedWriteable
    • getRelevantRatingThreshold

      public int getRelevantRatingThreshold()
      Return the rating threshold above which ratings are considered to be "relevant".
    • evaluate

      public EvalQueryQuality evaluate(String taskId, org.elasticsearch.search.SearchHit[] hits, List<RatedDocument> ratedDocs)
      Compute ReciprocalRank based on provided relevant document IDs.
      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 MeanReciprocalRank fromXContent(org.elasticsearch.common.xcontent.XContentParser parser)
    • toXContent

      public org.elasticsearch.common.xcontent.XContentBuilder toXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws IOException
      Specified by:
      toXContent in interface org.elasticsearch.common.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