如果我有三个包含字段 [result1, result2, result3] ElasticSearch 可以返回非空或非空字段吗?
我的意思是不在查询过滤器中,Elasticsearch 中是否有源或包含过滤器?
如果我有三个包含字段 [result1, result2, result3] ElasticSearch 可以返回非空或非空字段吗?
我的意思是不在查询过滤器中,Elasticsearch 中是否有源或包含过滤器?
是的。比如说,要获取 result2 为 null 且 result1 不为 null 的所有文档,您可以使用以下查询:
{
"query": {
"bool": {
"must": [
{
"exists": {
"field": "result1"
}
},
{
"bool": {
"must_not": {
"exists": {
"field": "result2"
}
}
}
}
]
}
}
}
要获取 result2 为 null或result1 不为 null 的文档,请将存在条件查询包装在should周围,然后包装在 bool 周围。