Package org.elasticsearch.index.rankeval
Class MeanReciprocalRank
java.lang.Object
org.elasticsearch.index.rankeval.MeanReciprocalRank
- All Implemented Interfaces:
NamedWriteable,Writeable,EvaluationMetric,org.elasticsearch.xcontent.ToXContent,org.elasticsearch.xcontent.ToXContentObject
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.
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 ClassesNested classes/interfaces inherited from interface org.elasticsearch.xcontent.ToXContent
org.elasticsearch.xcontent.ToXContent.DelegatingMapParams, org.elasticsearch.xcontent.ToXContent.MapParams, org.elasticsearch.xcontent.ToXContent.ParamsNested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V extends Object>, Writeable.Writer<V extends Object> -
Field Summary
FieldsFields inherited from interface org.elasticsearch.xcontent.ToXContent
EMPTY_PARAMS -
Constructor Summary
ConstructorsConstructorDescriptionMeanReciprocalRank(int relevantRatingThreshold, int k) Metric implementing Mean Reciprocal Rank (https://en.wikipedia.org/wiki/Mean_reciprocal_rank). -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanevaluate(String taskId, 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.static MeanReciprocalRankfromXContent(org.elasticsearch.xcontent.XContentParser parser) intReturn the rating threshold above which ratings are considered to be "relevant".final inthashCode()org.elasticsearch.xcontent.XContentBuildertoXContent(org.elasticsearch.xcontent.XContentBuilder builder, org.elasticsearch.xcontent.ToXContent.Params params) voidwriteTo(StreamOutput out) Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.elasticsearch.index.rankeval.EvaluationMetric
combineMethods inherited from interface org.elasticsearch.xcontent.ToXContentObject
isFragment
-
Field Details
-
NAME
- See Also:
-
-
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
- Specified by:
writeToin interfaceWriteable- Throws:
IOException
-
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
- Specified by:
getWriteableNamein interfaceNamedWriteable
-
getRelevantRatingThreshold
public int getRelevantRatingThreshold()Return the rating threshold above which ratings are considered to be "relevant". -
evaluate
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
-
toXContent
public org.elasticsearch.xcontent.XContentBuilder toXContent(org.elasticsearch.xcontent.XContentBuilder builder, org.elasticsearch.xcontent.ToXContent.Params params) throws IOException - Specified by:
toXContentin interfaceorg.elasticsearch.xcontent.ToXContent- Throws:
IOException
-
equals
-
hashCode
public final int hashCode()
-