我们假设您有5个来自同一用户的产品,并且您列出了它们 如果 user_id (字段)在5个文档中具有相同的值,我希望第五个文档的文档得分最少 分数应该从第一个到第五个逐渐减少
预期得分
"hits": [
{
"_type": "product",
"_id": "74162",
"_score": 1,
"_source": {
"user_id": 90
}
},
{
"_type": "product",
"_id": "6",
"_score": 1,
"_source": {
"user_id": 35
}
}
{
"_type": "product",
"_id": "2",
"_score": 0.9,
"_source": {
"user_id": 90
}
},
{
"_type": "product",
"_id": "3",
"_score": 0.8,
"_source": {
"user_id": 90
}
},
{
"_type": "product",
"_id": "4",
"_score": 0.7,
"_source": {
"user_id": 90
}
},
{
"_type": "product",
"_id": "5",
"_score": 0.6,
"_source": {
"user_id": 90
}
}
答案 0 :(得分:1)
您使用的是除了订购结果之外的分数吗?如果没有,那么你可以按user_id
订购您还可以指定定义这些结果的相关性的内容吗?
答案 1 :(得分:0)
根据_score
和user_id
排序可能对您有好处:
GET /my_index/_search
{
"sort" : [
{ "_score" : "desc" },
{ "uder_id" : "asc" }
],
"query" : {
//your query here
}
}
来源:https://www.elastic.co/guide/en/elasticsearch/reference/6.2/search-request-sort.html