Package org.elasticsearch.index.rankeval
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 java.lang.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 classMeanReciprocalRank.Detail
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringNAME
-
Constructor Summary
Constructors Constructor Description MeanReciprocalRank()MeanReciprocalRank(int relevantRatingThreshold, int k)Metric implementing Mean Reciprocal Rank (https://en.wikipedia.org/wiki/Mean_reciprocal_rank).
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)EvalQueryQualityevaluate(java.lang.String taskId, org.elasticsearch.search.SearchHit[] hits, java.util.List<RatedDocument> ratedDocs)Compute ReciprocalRank based on provided relevant document IDs.java.util.Optional<java.lang.Integer>forcedSearchSize()Metrics can define a size of the search hits windows they want to retrieve by overwriting this method.static MeanReciprocalRankfromXContent(org.elasticsearch.common.xcontent.XContentParser parser)intgetRelevantRatingThreshold()Return the rating threshold above which ratings are considered to be "relevant".java.lang.StringgetWriteableName()inthashCode()org.elasticsearch.common.xcontent.XContentBuildertoXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)voidwriteTo(org.elasticsearch.common.io.stream.StreamOutput out)-
Methods inherited from interface org.elasticsearch.index.rankeval.EvaluationMetric
combine
-
-
-
-
Field Detail
-
NAME
public static final java.lang.String NAME
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
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 Detail
-
writeTo
public void writeTo(org.elasticsearch.common.io.stream.StreamOutput out) throws java.io.IOException- Specified by:
writeToin interfaceorg.elasticsearch.common.io.stream.Writeable- Throws:
java.io.IOException
-
forcedSearchSize
public java.util.Optional<java.lang.Integer> forcedSearchSize()
Description copied from interface:EvaluationMetricMetrics 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:
forcedSearchSizein interfaceEvaluationMetric- Returns:
- the number of search hits this metrics requests
-
getWriteableName
public java.lang.String getWriteableName()
- Specified by:
getWriteableNamein interfaceorg.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(java.lang.String taskId, org.elasticsearch.search.SearchHit[] hits, java.util.List<RatedDocument> ratedDocs)
Compute ReciprocalRank based on provided relevant document IDs.- Specified by:
evaluatein interfaceEvaluationMetric- Parameters:
taskId- an identifier of the query for which the search ranking is evaluatedhits- the search result hitsratedDocs- the documents that contain the document rating for this query case- Returns:
- an
EvalQueryQualityinstance 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 java.io.IOException- Specified by:
toXContentin interfaceorg.elasticsearch.common.xcontent.ToXContent- Throws:
java.io.IOException
-
equals
public final boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public final int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-