弹性搜索,多重匹配过滤器? [英] ElasticSearch, multi-match with filter?
本文介绍了弹性搜索,多重匹配过滤器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
{
我在ES中有一个多匹配查询,并希望添加一个过滤器。 $$$
查询:这是一个测试,
fields:[subject ^ 2,message]
}
}
添加此过滤器的语法是什么?
我试过:
{
multi_match=> {
query=> list,
fields=> [username]
},
filter=> {
term=> {username=> slimkicker}
}
}
解决方案
根据您的需要,您必须将过滤器置于正确的位置。您有两个选项:
使用顶级过滤器并将过滤器仅应用于搜索结果,但不适用于构面
{
查询:{
multi_match{
查询:这是一个测试,
fields:[subject ^ 2,message]
}
},
filter:{
term:{username slimkicker}
}
}
使用过滤的查询并应用过滤器搜索结果和方面
{
查询:{
已过滤: {
查询:{
multi_match:{
query:这是一个测试,
fields:[subject ^ 2消息]
}
},
过滤器:{
term:{username:slimkicker}
}
}
}
}
I have a multi-match query in ES, and wish to add a filter.
{
"multi_match" : {
"query" : "this is a test",
"fields" : [ "subject^2", "message" ]
}
}
What is the syntax for adding this filter?
I tried:
{
"multi_match" => {
"query" => "list",
"fields" => [ "username" ]
},
"filter" => {
"term" => { "username" => "slimkicker"}
}
}
解决方案
Depending on what you need you have to put the filter in the proper position. You have two options:
Use a top-level filter and apply the filter only to the search results but not to the facets
{
"query" : {
"multi_match" {
"query" : "this is a test",
"fields" : [ "subject^2", "message" ]
}
},
"filter" : {
"term" : {"username":"slimkicker"}
}
}
Use a filtered query and apply the filter to both the search results and the facets
{
"query" :{
"filtered" : {
"query" : {
"multi_match" : {
"query" : "this is a test",
"fields" : [ "subject^2", "message" ]
}
},
"filter" : {
"term" : {"username":"slimkicker"}
}
}
}
}
这篇关于弹性搜索,多重匹配过滤器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文