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