gpt4 book ai didi

elasticsearch - random_score无法与 “should”一起正常使用

转载 作者:行者123 更新时间:2023-12-02 22:17:49 27 4
gpt4 key购买 nike

在以下代码中,无论我设置了什么种子,我总是总是首先获得“Alexander McQueen”产品。

如何更改搜索查询以正确地随机排列结果?

{
"query": {
"function_score": {
"random_score": {
"seed": 99287
},
"query": {
"bool": {
"should": [
{
"bool": {
"must": [
{
"query_string": {
"query": "(adidas originals)",
"default_operator": "AND",
"fields": [
"name^4",
"description"
]
}
},
{
"terms": {
"category": [
"Fashion",
"Sports",
"Other",
""
]
}
},
{
"term": {
"currency": {
"term": "USD"
}
}
}
]
}
},
{
"bool": {
"must": [
{
"query_string": {
"query": "(alexander mcqueen)",
"default_operator": "AND",
"fields": [
"name^4",
"description"
]
}
},
{
"terms": {
"category": [
"Fashion"
]
}
},
{
"term": {
"currency": {
"term": "USD"
}
}
}
]
}
}
]
}
}
}
},
"size": 40,
"from": 0
}

最佳答案

那是因为随机分数要乘以原始查询中的_score。如果您希望结果完全基于随机分数,则将boost_mode设置为replace(而不是默认的multiply)。

参见 function_score documentation

关于elasticsearch - random_score无法与 “should”一起正常使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21610434/

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