弹性搜索:存在过滤器不起作用



这是我的数据...

{"score":60,"name":"bill"},
{"score":50,"name":"john"},
{"score":null,"name":"sam"}

我希望编写一个过滤器范围查询,其中也应该包括空值。

我试过这个...并期望所有 3 个结果,但它返回 0 个结果 ...?

"filter": {
"bool": {
"must": [
{
"range": {
"score": {
"lte": 100
}
}
},
{
"exists": {
"field": "score"
}
}
]
}
}

任何帮助都非常感谢... 谢谢

您需要做的是bool/should您的range查询或缺少score字段

{
"query": {
"bool": {
"should": [
{
"range": {
"score": {
"lte": 100
}
}
},
{
"bool": {
"must_not": {
"exists": {
"field": "score"
}
}
}
}
]
}
}
}

最新更新