gpt4 book ai didi

ElasticSearch,与过滤器的多重匹配?

转载 作者:行者123 更新时间:2023-11-29 02:42:59 25 4
gpt4 key购买 nike

我在 ES 中有一个多匹配查询,并希望添加一个过滤器。

{
"multi_match" : {
"query" : "this is a test",
"fields" : [ "subject^2", "message" ]
}
}

添加此过滤器的语法是什么?

我试过:

{
"multi_match" => {
"query" => "list",
"fields" => [ "username" ]

},
"filter" => {
"term" => { "username" => "slimkicker"}
}
}

最佳答案

根据您的需要,您必须将过滤器放在适当的位置。您有两个选择:

使用顶级过滤器并将过滤器仅应用于搜索结果而不应用于构面

{
"query" : {
"multi_match" : {
"query" : "this is a test",
"fields" : [ "subject^2", "message" ]
}
},
"filter" : {
"term" : { "username": "slimkicker" }
}
}

使用过滤查询并将过滤器应用于搜索结果和构面

{
"query" : {
"filtered" : {
"query" : {
"multi_match" : {
"query" : "this is a test",
"fields" : [ "subject^2", "message" ]
}
},
"filter" : {
"term" : { "username": "slimkicker" }
}
}
}
}

关于ElasticSearch,与过滤器的多重匹配?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16776260/

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