Package org.elasticsearch.index.rankeval
Class RatedRequest
- java.lang.Object
-
- org.elasticsearch.index.rankeval.RatedRequest
-
- All Implemented Interfaces:
org.elasticsearch.common.io.stream.Writeable,org.elasticsearch.common.xcontent.ToXContent,org.elasticsearch.common.xcontent.ToXContentObject
public class RatedRequest extends java.lang.Object implements org.elasticsearch.common.io.stream.Writeable, org.elasticsearch.common.xcontent.ToXContentObjectDefinition 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 theSearchSourceBuilderthat 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} ] }
-
-
Constructor Summary
Constructors Constructor Description RatedRequest(java.lang.String id, java.util.List<RatedDocument> ratedDocs, java.util.Map<java.lang.String,java.lang.Object> params, java.lang.String templateId)Create a rated request with template ids and parameters.RatedRequest(java.lang.String id, java.util.List<RatedDocument> ratedDocs, org.elasticsearch.search.builder.SearchSourceBuilder evaluatedQuery)Create a rated request using aSearchSourceBuilderto define the evaluated query.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddSummaryFields(java.util.List<java.lang.String> summaryFields)booleanequals(java.lang.Object obj)static RatedRequestfromXContent(org.elasticsearch.common.xcontent.XContentParser parser)parse from rest representationorg.elasticsearch.search.builder.SearchSourceBuildergetEvaluationRequest()java.lang.StringgetId()return the user supplied request idjava.util.Map<java.lang.String,java.lang.Object>getParams()return the parameters if this request uses a template, otherwise this will be empty.java.util.List<RatedDocument>getRatedDocs()return the list of rated documents to evaluate.java.util.List<java.lang.String>getSummaryFields()returns a list of fields that should be included in the document summary for matched documentsjava.lang.StringgetTemplateId()return the parameters if this request uses a template, otherwise this will benull.inthashCode()java.lang.StringtoString()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)
-
-
-
Constructor Detail
-
RatedRequest
public RatedRequest(java.lang.String id, java.util.List<RatedDocument> ratedDocs, java.util.Map<java.lang.String,java.lang.Object> params, java.lang.String templateId)Create a rated request with template ids and parameters.- Parameters:
id- a unique name for this rated requestratedDocs- a list of document ratingsparams- template parameterstemplateId- a templare id
-
RatedRequest
public RatedRequest(java.lang.String id, java.util.List<RatedDocument> ratedDocs, org.elasticsearch.search.builder.SearchSourceBuilder evaluatedQuery)Create a rated request using aSearchSourceBuilderto define the evaluated query.- Parameters:
id- a unique name for this rated requestratedDocs- a list of document ratingsevaluatedQuery- the query that is evaluated
-
-
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
-
getEvaluationRequest
public org.elasticsearch.search.builder.SearchSourceBuilder getEvaluationRequest()
-
getId
public java.lang.String getId()
return the user supplied request id
-
getRatedDocs
public java.util.List<RatedDocument> getRatedDocs()
return the list of rated documents to evaluate.
-
getParams
public java.util.Map<java.lang.String,java.lang.Object> getParams()
return the parameters if this request uses a template, otherwise this will be empty.
-
getTemplateId
public java.lang.String getTemplateId()
return the parameters if this request uses a template, otherwise this will benull.
-
getSummaryFields
public java.util.List<java.lang.String> getSummaryFields()
returns a list of fields that should be included in the document summary for matched documents
-
addSummaryFields
public void addSummaryFields(java.util.List<java.lang.String> summaryFields)
-
fromXContent
public static RatedRequest fromXContent(org.elasticsearch.common.xcontent.XContentParser parser)
parse from rest representation
-
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
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
equals
public final boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public final int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-