gpt4 book ai didi

elasticsearch - 在Elasticsearch中的 bool 查询中, “must”的Min_score

转载 作者:行者123 更新时间:2023-12-02 22:19:31 24 4
gpt4 key购买 nike

有没有一种方法可以对Elasticsearch中的 bool(boolean) 查询中的must子句应用最低分数。

我希望能够做这样的事情:

{
"query": {
"bool": {
"must": [
{
"match": {
"name": {
"query":"A Name",
"min_score": 0.3
}
}
},
{
"match": {
"address": {
"query":"1 Somewhere Street, Somewhereset, UK",
"min_score": 0.3
}
}
}
]
}
}
}

对于返回的文档,这将要求名称查询的得分大于0.3,地址查询的得分大于0.3。这是为了阻止返回真正的好名字匹配,尽管地址匹配很糟糕(例如,仅匹配1),反之亦然。

我当前使用的是Elasticsearch 1.5,但过去也希望使用2.3。

最佳答案

试试这个,让我知道它是否有效:

{
"query": {
"bool": {
"must": [
{
"function_score": {
"query": {
"match": {
"name": {
"query": "A Name"
}
}
},
"min_score": 0.3
}
},
{
"function_score": {
"query": {
"match": {
"address": {
"query": "1 Somewhere Street, Somewhereset, UK"
}
}
},
"min_score": 0.3
}
}
]
}
}
}

关于elasticsearch - 在Elasticsearch中的 bool 查询中, “must”的Min_score,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38499487/

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