![](/img/trans.png)
[英]Elastic Seach - filter top N documents by score and then sort by field
[英]Elastic Search sort documents with same score using another field value
我正在使用弹性搜索,我想根据更多的“喜欢”字段 - 存储在所有文档中的整数类型,对具有相同分数的文档进行排序。 代码 -
query: {
multi_match: {
query: "some cooler",
type: "most_fields",
fields: ["info1", "info2", "info3"]
}
}
您应该检查排序文档
只需在json上按分数添加排序部分,然后在自定义字段中添加。
{
"query" : {...},
"sort" : [
"_score",
{ "likes" : {"order" : "desc"}}
]
}
得分顺序默认为'desc'。 其他字段默认为'asc',因此您需要为'喜欢'字段定义'desc'顺序,如果这是您想要的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.