【发布时间】:2018-02-16 17:38:39
【问题描述】:
我想运行一个查询来查看有多少文档存储了一个空对象作为它们的值。例如,它会返回如下文档:
"hits": [
{
"_source": {
"otherfield": "abc",
"somefield": {}
}
}
]
但不是没有字段/具有未定义值的字段,或具有包含属性的对象的字段:
"hits": [
{
"_source": {
"otherfield": "abc",
// <-- note no "somefield"
}
},
{
"_source": {
"otherfield": "abc",
"somefield": { "field1": "value1" }
}
}
]
但是我的查询也会返回字段是具有"somefield": { "field1": "value1" }等属性的对象的文档
GET /documents/_search
{
"query": {
"bool": {
"must_not": [
{
"exists": {
"field": "somefield.field1"
}
},
]
"should": [
{
"exists": {
"field": "somefield"
}
}
],
"minimum_should_match": 2
}
}
}
使用 Elasticsearch 5.4
【问题讨论】:
标签: elasticsearch