Elasticsearch 2.4,存在用于嵌套对象不工作的过滤器 [英] Elasticsearch 2.4, Exists filter for nested objects not working
本文介绍了Elasticsearch 2.4,存在用于嵌套对象不工作的过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的映射是:
"properties": {
"user": {
"type": "nested",
"properties": {
"id": {
"type": "integer"
},
"is_active": {
"type": "boolean",
"null_value": false
},
"username": {
"type": "string"
}
}
},
我想获取所有文档没有用户
字段。
I want to get all documents that do not have a user
field.
我试过:
GET /index/type/_search
{
"query": {
"bool": {
"must_not": [
{
"exists": {
"field": "user"
}
}
]
}
}
}
哪些返回所有文档。
根据 ElasticSearch 2 .x存在过滤器用于嵌套字段不工作,我也尝试过:
Which returns all documents. Based on ElasticSearch 2.x exists filter for nested field doesn't work, I also tried:
GET /index/type/_search
{
"query": {
"nested": {
"path": "user",
"query": {
"bool": {
"must_not": [
{
"exists": {
"field": "user"
}
}
]
}
}
}
}
}
哪个返回0个文件。
正确的查询是什么,以获取所有文档缺少用户
字段?
What is the correct query to get all documents missing the user
field?
推荐答案
我发现正确的语法,应该是:
I found the correct syntax, it should have been:
GET /index/type/_search
{
"query": {
"bool": {
"must_not": [
{
"nested": {
"path": "user",
"query": {
"exists": {
"field": "user"
}
}
}
}
]
}
}
}
这篇关于Elasticsearch 2.4,存在用于嵌套对象不工作的过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文