本文介绍了Elasticsearch中的嵌套选择查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我必须在elasticsearch中转换以下查询:
I have to convert the following query in elasticsearch :
select * from index where observable not in (select observable from index where tags = 'whitelist')我读到应该在非过滤器"中使用过滤器,但是我不知道该怎么做. 谁能帮我? 谢谢
I read that I should use a Filter in a Not Filter but I don't understand how to do. Can anyone help me? Thanks
除了具有"whitelist"标签的标签外,我必须获取所有标签,但是我还需要检查白名单中是否不包含黑名单元素.
I have to get all except those that have 'whitelist' tag but I need to check also that nothing of the blacklist element is contained into the whitelist.
推荐答案您的SQL查询可以简化为:
Your SQL query can be simplified to this:
select * from index where tags not in ('whitelist')因此,对应的" ES查询将是
As a result the "corresponding" ES query would be
curl -XPOST localhost:9200/index/_search -d '{ "query": { "filtered": { "filter": { "bool": { "must_not": { "terms": { "tags": [ "whitelist" ] } } } } } } }'或使用not过滤器而不是bool/must_not的其他过滤器:
or another using the not filter instead of bool/must_not:
curl -XPOST localhost:9200/index/_search -d '{ "query": { "filtered": { "filter": { "not": { "terms": { "tags": [ "whitelist" ] } } } } } }'更多推荐
Elasticsearch中的嵌套选择查询
发布评论