easy-es icon indicating copy to clipboard operation
easy-es copied to clipboard

关于 isNull 的问题

Open dejavuhuh opened this issue 10 months ago • 0 comments

想知道 easy-es 应该如何表达下面这种查询逻辑:

select * from my_index where a is null or a in ('1', '2', '3')

由于 isNull 方法被移除了,根据 #65 的提示我尝试了下面这种写法

wrapper.and {
    it.not().exists("a")
        .or()
        .`in`("a", listOf('1', '2', '3'))
}

但是最终生成出来的查询语句有问题:

{
    "query": {
        "bool": {
            "must": [
                {
                    "bool": {
                        "should": [
                            {
                                "exists": {
                                    "boost": 1.0,
                                    "field": "a"
                                }
                            },
                            {
                                "terms": {
                                    "a": [
                                        "1",
                                        "2",
                                        "3"
                                    ]
                                }
                            }
                        ]
                    }
                }
            ]
        }
    }
}

最终的实际效果变成 a is not null or in ('1', '2', '3') 了

dejavuhuh avatar Jun 22 '25 01:06 dejavuhuh