小编Raj*_*esh的帖子

弹性搜索 ---: MUST_NOT 查询不起作用

我有一个查询,我想在其中添加一个 Must_not 子句,该子句将丢弃某些字段具有空白数据的所有记录。我尝试了很多方法,但没有一个有效。当我对其他特定字段发出相同的查询(如下所述)时,它工作正常。

此查询应获取没有“registrationType1”字段为空/空白的所有记录

query:
{
"size": 20,
"_source": [
"registrationType1"
],
"query": {
"bool": {
"must_not": [
{
"term": {
"registrationType1": ""
}
}
]
}
}
}
Run Code Online (Sandbox Code Playgroud)

下面的结果仍然包含带有空值的“registrationType1”

results:

**"_source": {
"registrationType1": ""}}
, * {
"_index": "oh_animal",
"_type": "animals",
"_id": "3842002",
"_score": 1,
"_source": {
"registrationType1": "A&R"}}
, * {
"_index": "oh_animal",
"_type": "animals",
"_id": "3842033",
"_score": 1,
"_source": {
"registrationType1": "AMHA"}}
, * {
"_index": "oh_animal",
"_type": "animals",
"_id": "3842213",
"_score": 1,
"_source": {
"registrationType1": "AMHA"}} …
Run Code Online (Sandbox Code Playgroud)

elasticsearch

5
推荐指数
1
解决办法
4353
查看次数

标签 统计

elasticsearch ×1