弹性搜索不过滤和过滤 [英] Elastic search Not filter inside and filter
本文介绍了弹性搜索不过滤和过滤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
中添加一个not过滤器样本输入:
{
pre>
query:{
filtered:{
query:{
query_string:{
query:error,
fields:[
request
]
}
},
filter
和:[
{
条款:{
hashtag:[
br2
]
},
not:{
terms:{
hashtag:[
br1
]
}
}
}
]
}
}
}
},
}
但以上是给出错误,我也尝试了各种组合,但徒劳无功。
以上只是一个例子,我需要一个查询,其中包含和,not过滤器。解决方案你忘记了filters数组。
写这样:
{
from:0,
size:25,
query:{
filtered:{
查询:{
match_all:{}
},
过滤器:{
和:{
filters [{
term:{
field1:val1
}
},{
not:{
filter :{
term:{
field2:val2,
}
}
}
}
]
}
}
}
}
}
I am trying to add a "not" filter inside "and" filter
Sample input:
{ "query":{ "filtered":{ "query":{ "query_string":{ "query":"error", "fields":[ "request" ] } }, "filter":{ and:[ { "terms":{ "hashtag":[ "br2" ] }, "not":{ "terms":{ "hashtag":[ "br1" ] } } } ] } } } }, }
But above is giving error, i also tried various combination but in vain. Above is just an example in short i require a query in which both "and", "not" filter are present.
解决方案you forgot the "filters" array.
Write it like this :
{ "from" : 0, "size" : 25, "query" : { "filtered" : { "query" : { "match_all" : {} }, "filter" : { "and" : { "filters" : [{ "term" : { "field1" : "val1" } }, { "not" : { "filter" : { "term" : { "field2" : "val2", } } } } ] } } } } }
这篇关于弹性搜索不过滤和过滤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文