我正在执行一个Elasticsearch查询,该查询过滤掉所有文档,其中某个特定字段通过
query: {
filtered: {
filter: {
bool: {
should: {
bool: {
must: {
term: 'someCondition'
},
must_not: {
missing: {field: 'somefield'}
}
}
}
}
}
}
}这与预期的一样。现在,我需要使此missing筛选器具有条件,以便只有在另一个字段不存在时才匹配。
我曾尝试将我的must_not转换为should,如下所示:
should: {
missing: {field: 'somefield'},
exists: {'field': 'somotherfield'}
}但这似乎并不管用。
澄清一下:"SELECT * from docs (某字段不为空或其他字段不为空)“
发布于 2016-07-19 15:39:16
尝试如下查询:
"filters" : [ {
"missing" : {
"field" : "somefield"
}
}, {
"not" : {
"filter" : {
"missing" : {
"field" : "somotherfield"
}
}
}
} ]https://stackoverflow.com/questions/38434027
复制相似问题