Elasticsearch:结合功能分数 [英] Elasticsearch: combine function scores
本文介绍了Elasticsearch:结合功能分数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用三个函数
为es查询评分:
I'm scoring es query with three functions
:
{
"query": {
"function_score": {
"query": {
"bool": {
...
}
}
}
},
"score_mode": "multiply",
"boost_mode": "replace",
"functions": [
{ f1 },
{ f2 },
{ f3 }
]
}
所以分数将是: f1(doc)* f2(doc)* f3(doc)
.
但是我想要的是 f1(doc)* f2(doc)+ f3(doc)
,有解决方案吗?
But what I want is f1(doc) * f2(doc) + f3(doc)
, any solutions?
推荐答案
这可能有用,即我们将函数f1和f2的分数相乘,然后将该分数添加到查询分数中,这是另一个 function_score
仅查询f3.
This might work, i.e. we multiply the scores of functions f1 and f2 together and then we add that score to the query score which is another function_score
query just for f3.
{
"query": {
"function_score": {
"query": {
"function_score": {
"query": { "match_all": {}},
"functions": [
{
"f3": {...}
}
]
}
},
"functions": [
{
"f1": {...}
},
{
"f2": {...}
}
],
"score_mode": "multiply",
"boost_mode": "sum"
}
}
}
这篇关于Elasticsearch:结合功能分数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文