我在文档中有一个嵌套数据映射,我想查询嵌套字段是否不存在。
这个弹性查询正在工作,但是这个查询的弹性 DSL 表示是什么?
获取产品/_search
{
"query": {
"bool": {
"must_not": [
{
"nested": {
"path": "attributes",
"query": {
"exists": {
"field": "attributes.value"
}
}
}
}
]
}
}
}
我试过这个,但它不起作用
ProductDocument.search().query(
"nested",
path="attributes",
query=(~Q('exists', field='attributes.value'))
)
这个 DSL 查询表示为,我认为这是错误的
{
"query": {
"nested": {
"path": "attributes",
"query": {
"bool": {
"must_not": [{
"exists": {
"field": "attributes.value"
}
}]
}
}
}
}
}
注意:我使用的是 elastic 6.7,elasticsearch-dsl 6.4.2
最后,我找到了查询
ProductDocument.search().query(~Q(
"nested",
path="attributes",
query=Q("exists", field='attributes.value'))
))
这可能对某人有帮助
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句