Package org.elasticsearch.index.rankeval
Class RatedRequest
- java.lang.Object
-
- org.elasticsearch.index.rankeval.RatedRequest
-
- All Implemented Interfaces:
Writeable,ToXContent,ToXContentObject
public class RatedRequest extends Object implements Writeable, 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 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} ] }
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params
-
Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V>
-
-
Field Summary
-
Fields inherited from interface org.elasticsearch.common.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, 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(List<String> summaryFields)booleanequals(Object obj)static RatedRequestfromXContent(XContentParser parser)parse from rest representationSearchSourceBuildergetEvaluationRequest()StringgetId()return the user supplied request idMap<String,Object>getParams()return the parameters if this request uses a template, otherwise this will be empty.List<RatedDocument>getRatedDocs()return the list of rated documents to evaluate.List<String>getSummaryFields()returns a list of fields that should be included in the document summary for matched documentsStringgetTemplateId()return the parameters if this request uses a template, otherwise this will benull.inthashCode()StringtoString()XContentBuildertoXContent(XContentBuilder builder, ToXContent.Params params)voidwriteTo(StreamOutput out)Write this into the StreamOutput.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.elasticsearch.common.xcontent.ToXContentObject
isFragment
-
-
-
-
Constructor Detail
-
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 requestratedDocs- a list of document ratingsparams- template parameterstemplateId- a templare id
-
RatedRequest
public RatedRequest(String id, List<RatedDocument> ratedDocs, 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(StreamOutput out) throws IOException
Description copied from interface:WriteableWrite this into the StreamOutput.- Specified by:
writeToin interfaceWriteable- Throws:
IOException
-
getEvaluationRequest
public 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 benull.
-
getSummaryFields
public List<String> getSummaryFields()
returns a list of fields that should be included in the document summary for matched documents
-
fromXContent
public static RatedRequest fromXContent(XContentParser parser)
parse from rest representation
-
toXContent
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException
- Specified by:
toXContentin interfaceToXContent- Throws:
IOException
-
-