我在一个ES索引中有不同的type_id,并且希望给不同的值type_id不同的分数,以使某些类型的搜索结果排名更高。
{
"query":{
"bool":{
"must":[
{"terms":{"type_id":[9,10]}}
],
"should":[
{"match":{ "display_name":{"query":"keyword","boost":10}}},
{"match":{ "description":{"query":"keyword","boost":2}}}
]
}
}
}
当display_name
和description
相同时,我想使type_id
9的匹配分数高于type_id
10。
请在这个问题上指导我。谢谢。
1条答案
按热度按时间wz1wpwve1#
你可以像下面这样对你的查询进行分组,并使用boost来给某些id更多的权重。
编辑:注解中的查询,可以使用function_score