Hello,World

Elasticsearch has_child 查询 怎么排序?

Elasticsearch | 作者 zx3271234 | 发布于2017年11月27日 | 阅读数:4204

父子文档,一对多关系,使用has_child通过子文档来查询父文档。查询完之后怎么通过子文档的某个字段来对父文档进行排序呢?
已邀请:

aa1356889

赞同来自:

 
{
"query": {
"bool": {
"must": [
{"match":{"productName":"花"}},
{
"has_child": {
"type": "dealer_opration",
"score_mode": "max",
"query": {
"function_score": {
"query": {
"bool": {
"must": [{
"term": {
"dealer_opration_dealer_id": 1
}

}]
}
},
"script_score": {
"script": "_score * doc['dealer_opration_count'].value"
}
}

}
}
}]
}
},
"sort": [{
"_score": {
"order": "desc"
}
}]
}
不做伸手党伸手党 dealer_opration_count为你的子节点id

要回复问题请先登录注册