Class RatedRequest

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

public class RatedRequest extends Object implements org.elasticsearch.common.io.stream.Writeable, org.elasticsearch.xcontent.ToXContentObject
Definition of a particular query in the ranking evaluation request.
This usually represents a single user search intent and consists of an id (ideally human readable and referencing the search intent), the list of indices to be queries and the SearchSourceBuilder that will be used to create the search request for this search intent.
Alternatively, a template id and template parameters can be provided instead.
Finally, a list of rated documents for this query also needs to be provided.

The json structure in the rest request looks like this:

 {
    "id": "coffee_query",
    "request": {
        "query": {
            "match": { "beverage": "coffee" }
        }
    },
    "summary_fields": ["title"],
    "ratings": [
        {"_index": "my_index", "_id": "doc1", "rating": 0},
        {"_index": "my_index", "_id": "doc2","rating": 3},
        {"_index": "my_index", "_id": "doc3", "rating": 1}
    ]
 }
 
  • Nested Class Summary

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

    org.elasticsearch.xcontent.ToXContent.DelegatingMapParams, org.elasticsearch.xcontent.ToXContent.MapParams, org.elasticsearch.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 inherited from interface org.elasticsearch.xcontent.ToXContent

    EMPTY_PARAMS
  • Constructor Summary

    Constructors
    Constructor
    Description
    RatedRequest(String id, List<RatedDocument> ratedDocs, Map<String,Object> params, String templateId)
    Create a rated request with template ids and parameters.
    RatedRequest(String id, List<RatedDocument> ratedDocs, org.elasticsearch.search.builder.SearchSourceBuilder evaluatedQuery)
    Create a rated request using a SearchSourceBuilder to define the evaluated query.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addSummaryFields(List<String> summaryFieldsToAdd)
     
    final boolean
     
    fromXContent(org.elasticsearch.xcontent.XContentParser parser)
    parse from rest representation
    org.elasticsearch.search.builder.SearchSourceBuilder
     
    return the user supplied request id
    return the parameters if this request uses a template, otherwise this will be empty.
    return the list of rated documents to evaluate.
    returns a list of fields that should be included in the document summary for matched documents
    return the parameters if this request uses a template, otherwise this will be null.
    final int
     
     
    org.elasticsearch.xcontent.XContentBuilder
    toXContent(org.elasticsearch.xcontent.XContentBuilder builder, org.elasticsearch.xcontent.ToXContent.Params xContentParams)
     
    void
    writeTo(org.elasticsearch.common.io.stream.StreamOutput out)
     

    Methods inherited from class java.lang.Object

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

    Methods inherited from interface org.elasticsearch.xcontent.ToXContentObject

    isFragment
  • Constructor Details

    • RatedRequest

      public RatedRequest(String id, List<RatedDocument> ratedDocs, Map<String,Object> params, String templateId)
      Create a rated request with template ids and parameters.
      Parameters:
      id - a unique name for this rated request
      ratedDocs - a list of document ratings
      params - template parameters
      templateId - a templare id
    • RatedRequest

      public RatedRequest(String id, List<RatedDocument> ratedDocs, org.elasticsearch.search.builder.SearchSourceBuilder evaluatedQuery)
      Create a rated request using a SearchSourceBuilder to define the evaluated query.
      Parameters:
      id - a unique name for this rated request
      ratedDocs - a list of document ratings
      evaluatedQuery - the query that is evaluated
  • 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
    • getEvaluationRequest

      public org.elasticsearch.search.builder.SearchSourceBuilder getEvaluationRequest()
    • getId

      public String getId()
      return the user supplied request id
    • getRatedDocs

      public List<RatedDocument> getRatedDocs()
      return the list of rated documents to evaluate.
    • getParams

      public Map<String,Object> getParams()
      return the parameters if this request uses a template, otherwise this will be empty.
    • getTemplateId

      public String getTemplateId()
      return the parameters if this request uses a template, otherwise this will be null.
    • getSummaryFields

      public List<String> getSummaryFields()
      returns a list of fields that should be included in the document summary for matched documents
    • addSummaryFields

      public void addSummaryFields(List<String> summaryFieldsToAdd)
    • fromXContent

      public static RatedRequest fromXContent(org.elasticsearch.xcontent.XContentParser parser)
      parse from rest representation
    • toXContent

      public org.elasticsearch.xcontent.XContentBuilder toXContent(org.elasticsearch.xcontent.XContentBuilder builder, org.elasticsearch.xcontent.ToXContent.Params xContentParams) throws IOException
      Specified by:
      toXContent in interface org.elasticsearch.xcontent.ToXContent
      Throws:
      IOException
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public final boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public final int hashCode()
      Overrides:
      hashCode in class Object