Package org.opensearch.index.rankeval
Interface EvaluationMetric
- All Superinterfaces:
NamedWriteable,org.opensearch.core.xcontent.ToXContent,org.opensearch.core.xcontent.ToXContentObject,Writeable
- All Known Implementing Classes:
DiscountedCumulativeGain,ExpectedReciprocalRank,MeanReciprocalRank,PrecisionAtK,RecallAtK
public interface EvaluationMetric
extends org.opensearch.core.xcontent.ToXContentObject, NamedWriteable
Implementations of
EvaluationMetric need to provide a way to compute the quality metric for
a result list returned by some search (@link SearchHits) and a list of rated documents.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.opensearch.core.xcontent.ToXContent
org.opensearch.core.xcontent.ToXContent.DelegatingMapParams, org.opensearch.core.xcontent.ToXContent.MapParams, org.opensearch.core.xcontent.ToXContent.ParamsNested classes/interfaces inherited from interface org.opensearch.common.io.stream.Writeable
Writeable.Reader<V extends Object>, Writeable.WriteableRegistry, Writeable.Writer<V extends Object> -
Field Summary
Fields inherited from interface org.opensearch.core.xcontent.ToXContent
EMPTY_PARAMS -
Method Summary
Modifier and TypeMethodDescriptiondefault doublecombine(Collection<EvalQueryQuality> partialResults) Combine severalEvalQueryQualityresults into the overall evaluation score.evaluate(String taskId, SearchHit[] hits, List<RatedDocument> ratedDocs) Evaluates a single ranking evaluation case.static List<org.opensearch.index.rankeval.RatedDocument.DocumentKey>filterUnratedDocuments(List<RatedSearchHit> ratedHits) FilterRatedSearchHits that do not have a rating.default OptionalIntMetrics can define a size of the search hits windows they want to retrieve by overwriting this method.static List<RatedSearchHit>joinHitsWithRatings(SearchHit[] hits, List<RatedDocument> ratedDocs) Joins hits with rated documents using the joint _index/_id document key.Methods inherited from interface org.opensearch.common.io.stream.NamedWriteable
getWriteableNameMethods inherited from interface org.opensearch.core.xcontent.ToXContent
toXContentMethods inherited from interface org.opensearch.core.xcontent.ToXContentObject
isFragment
-
Method Details
-
evaluate
Evaluates a single ranking evaluation case.- 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
-
joinHitsWithRatings
Joins hits with rated documents using the joint _index/_id document key. -
filterUnratedDocuments
static List<org.opensearch.index.rankeval.RatedDocument.DocumentKey> filterUnratedDocuments(List<RatedSearchHit> ratedHits) FilterRatedSearchHits that do not have a rating. -
combine
Combine severalEvalQueryQualityresults into the overall evaluation score. This defaults to averaging over the partial results, but can be overwritten to obtain a different behavior. -
forcedSearchSize
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.- Returns:
- the number of search hits this metrics requests
-