python操作es更新某个字段的名字,不根据id

body = {
        "query": {
            "term": {
                "group": {
                    "value": group_name  # 根据这个字段更新
                }
            }

        },
        "script": {
            "lang": "painless",
            "source": "ctx._source.group=params.group",  # group字段
            "params": {
                "group": new_group_name
            }
        }
    }
    try:
        res = es.update_by_query(name, body=body)
        print(res)
        return 1
    except:
        return 0

 

posted @ 2020-07-23 18:13  阿磊小哥哥呀  阅读(1192)  评论(0编辑  收藏  举报