Class DiscountedCumulativeGain

java.lang.Object
org.elasticsearch.index.rankeval.DiscountedCumulativeGain
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 DiscountedCumulativeGain
extends java.lang.Object
implements EvaluationMetric
Metric implementing Discounted Cumulative Gain. The `normalize` parameter can be set to calculate the normalized NDCG (set to false by default).
The optional `unknown_doc_rating` parameter can be used to specify a default rating for unlabeled documents.
See Also:
Discounted Cumulative Gain
  • Nested Class Summary

    Nested Classes
    Modifier and Type Class Description
    static class  DiscountedCumulativeGain.Detail  

    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 java.lang.Object>, org.elasticsearch.common.io.stream.Writeable.Writer<V extends java.lang.Object>
  • Field Summary

    Fields
    Modifier and Type Field Description
    static java.lang.String NAME  

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

    EMPTY_PARAMS
  • Constructor Summary

    Constructors
    Constructor Description
    DiscountedCumulativeGain()  
    DiscountedCumulativeGain​(boolean normalize, java.lang.Integer unknownDocRating, int k)  
  • Method Summary

    Modifier and Type Method Description
    boolean equals​(java.lang.Object obj)  
    EvalQueryQuality evaluate​(java.lang.String taskId, org.elasticsearch.search.SearchHit[] hits, java.util.List<RatedDocument> ratedDocs)
    Evaluates a single ranking evaluation case.
    java.util.OptionalInt forcedSearchSize()
    Metrics can define a size of the search hits windows they want to retrieve by overwriting this method.
    static DiscountedCumulativeGain fromXContent​(org.elasticsearch.common.xcontent.XContentParser parser)  
    java.lang.Integer getUnknownDocRating()
    get the rating used for unrated documents
    java.lang.String getWriteableName()  
    int hashCode()  
    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

    • DiscountedCumulativeGain

      public DiscountedCumulativeGain()
    • DiscountedCumulativeGain

      public DiscountedCumulativeGain​(boolean normalize, java.lang.Integer unknownDocRating, int k)
      Parameters:
      normalize - If set to true, dcg will be normalized (ndcg) See https://en.wikipedia.org/wiki/Discounted_cumulative_gain
      unknownDocRating - the rating for documents the user hasn't supplied an explicit rating for
      k - the search window size all request use.
  • Method Details

    • writeTo

      public void writeTo​(org.elasticsearch.common.io.stream.StreamOutput out) throws java.io.IOException
      Specified by:
      writeTo in interface org.elasticsearch.common.io.stream.Writeable
      Throws:
      java.io.IOException
    • getWriteableName

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

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

      public java.util.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​(java.lang.String taskId, org.elasticsearch.search.SearchHit[] hits, java.util.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 DiscountedCumulativeGain 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:
      toXContent in interface org.elasticsearch.common.xcontent.ToXContent
      Throws:
      java.io.IOException
    • equals

      public final boolean equals​(java.lang.Object obj)
      Overrides:
      equals in class java.lang.Object
    • hashCode

      public final int hashCode()
      Overrides:
      hashCode in class java.lang.Object