pmi*_*hev 3 elasticsearch elasticsearch-dsl elasticsearch-2.0
我的映射是:
"properties": {
"user": {
"type": "nested",
"properties": {
"id": {
"type": "integer"
},
"is_active": {
"type": "boolean",
"null_value": false
},
"username": {
"type": "string"
}
}
},
Run Code Online (Sandbox Code Playgroud)
我想获取所有没有user字段的文档。
我试过了:
GET /index/type/_search
{
"query": {
"bool": {
"must_not": [
{
"exists": {
"field": "user"
}
}
]
}
}
}
Run Code Online (Sandbox Code Playgroud)
返回所有文档。基于ElasticSearch 2.x,存在用于嵌套字段的过滤器不起作用的问题,我也尝试过:
GET /index/type/_search
{
"query": {
"nested": {
"path": "user",
"query": {
"bool": {
"must_not": [
{
"exists": {
"field": "user"
}
}
]
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
返回0个文档。
使所有缺少该user字段的文档的正确查询是什么?
我找到了正确的语法,应该是:
GET /index/type/_search
{
"query": {
"bool": {
"must_not": [
{
"nested": {
"path": "user",
"query": {
"exists": {
"field": "user"
}
}
}
}
]
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1034 次 |
| 最近记录: |