July 2015
Intermediate to advanced
192 pages
3h 38m
English
As there are different answers for each question and each query matches against each answer, there should be some mechanism to aggregate the score of each answer to form a final score for the parent, that is, the question:
curl -XPOST 'localhost:9200/posts/post/_search' -d '{
"query": {
"has_child": {
"type": "rating",
"query": {
"function_score": {
"functions": [
{
"field_value_factor": {
"field": "rating"
}
}
]
}
},
"score_mode": "sum"
}
}
}'And the output is as follows:
{ "took" : 5, "timed_out" : false, "_shards" : { "total" : 5, "successful" : 5, "failed" : 0 }, "hits" : { "total" : 3, "max_score" : 78.0, "hits" : [ { "_index" : "posts", "_type" : "post", "_id" : "1", "_score" : 78.0, ...Read now
Unlock full access