gpt4 book ai didi

elasticsearch - elasticsearch是否可以结合score_mode用于function_score查询

转载 作者:行者123 更新时间:2023-12-03 01:00:29 26 4
gpt4 key购买 nike

我有一个带有2个衰减函数(均为高斯)和script_score函数的function_score查询。在script_score函数中,我将几个分数相加并相乘。现在,我想将结果与on gauss函数(位置)相乘,然后将其与另一个gauss函数(creation_date)相加。我想这样做是为了使新文档得到加强。

我该如何实现?使用function_score查询的score_mode,我只能相乘或相加。

{
"query": {
"function_score": {
"functions": [
{
"gauss": {
"location": {
"origin": {
"lon": 16.37,
"lat": 48.21
},
"scale": "100km",
"offset": "15km",
"decay": 0.3
}
}
},
{
"gauss": {
"creation_date": {
"scale": "30d",
"offset": "20d",
"decay": 0.1
}
}
},
{
"script_score": {
"lang": "expression",
"script": "(((doc['value_a'].value + doc['value_b'] + 1) * boost_a) + (ln(sqrt(doc['value_c'].value + 1)) * boost_c))",
"params": {
"boost_a": 0.2,
"boost_b": 0.5
}
}
}
],
"query": {
"match_all": {}
},
"score_mode": "multiply",
"boost_mode": "multiply"
}
},
"sort": {
"_score": "desc"
}
}

提前致谢。

最佳答案

我找到了解决方案。

{
"query": {
"function_score": {
"functions": {
"gauss": {
"creation_date": {
"scale": "30d",
"offset": "20d",
"decay": 0.1
}
}
},
"query": {
"function_score": {
"functions": [
{
"gauss": {
"location": {
"origin": {
"lon": 16.37,
"lat": 48.21
},
"scale": "100km",
"offset": "15km",
"decay": 0.3
}
}
},
{
"script_score": {
"lang": "expression",
"script": "(((doc['value_a'].value + doc['value_b'] + 1) * boost_a) + (ln(sqrt(doc['value_c'].value + 1)) * boost_c))",
"params": {
"boost_a": 0.2,
"boost_b": 0.5
}
}
}
],
"query": {
"match_all": {}
},
"score_mode": "multiply",
"boost_mode": "multiply"
}
}
},
"score_mode": "multiply",
"boost_mode": "sum"
},
"sort": {
"_score": "desc"
}
}

关于elasticsearch - elasticsearch是否可以结合score_mode用于function_score查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38498877/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com