0
我试图构建弹性搜索查询not
使用bool
,因为not
已被弃用。例如。匹配不属于[email protected]
的所有文档。弹性搜索查询使用bool而不是
我试着用这些elasticsearch-DSL(以下这篇文章https://www.elastic.co/blog/lost-in-translation-boolean-operations-and-filters-in-the-bool-query):
{'query': {
'bool': {
'must_not': [{
'match': {
'author': '[email protected]'
}
}]
}
}}
这虽然比其他'author': '[email protected]'
文件存在不返回任何结果。
我也试过
{'query': {
'bool': {
'must_not': [{
'term': {
'author': '[email protected]'
}
}]
}
}}
这将返回的文件,其中一些有'author': '[email protected]'
和一些不混合。
你应该尝试在必须同级别添加must_not。像:bool> must,must_not。另一方面,应该指的基准级是“或”。有了这个或一些不需要的文档可以出现。 – hkulekci
您可以尝试创建一个关于您的搜索的真句子。例如,我想获取不是用户自己的文档的文档,而且它们是私人的。那么,你应该查询什么?完成我们的句子。 – hkulekci