且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

弹性搜索Groovy脚本eachWithIndex

更新时间:2023-12-05 14:21:58

p>

Have you tried this?

ctx._source.academies.removeAll { it['academy_id'] == academy_id }

如果您需要检查 academy_id 匹配项目列表,则可以使用以下:(封闭应满足条件)

In case you need to check academy_id matching a list of items, then below can be used: (The closure should satisfy a criteria)

ctx._source.academies.removeAll { it['academy_id'] in [academy_id, some_other_id] }

从弹性搜索的角度来看,我认为脚本可以重写如下: / p>

From an elastic search perspective, I suppose the script can be rewritten as below:

{
    "script" : "ctx._source.academies.removeAll { it['academy_id'] in academy_ids }",
    "params": {
        "academy_ids": [344, 345, 346]
    }
}