# Official document: Modify elasticsearch data: # update_by_query: def update_order_info_by_id (data_list): update_body = {"query": {"term": {"_ id ": ID _ }}, "script": {"inline": "CTX. _ source. order_info = Params. order_info "," Params ": {'order _ info': {" test ":" 999 qwwe ", 'aa':" sssqweee "}}} resp = es. update_by_query (Index = index, doc_type = doc_type, body = update_body) # batch modify def update_order_info_by_id (data_list): # res_set = set () res_set = [] for ID _ in data_list: res_dict = dict () res_dict ["_ Index"] = index res_dict ["_ op_type"] = "Update" res_dict ["_ type"] = doc_type res_dict ["_ id"] = "comment" # update_body = {"script" must be passed for the ID during batch modification ": {"inline": "CTX. _ source. order_info = order_info "," Params ": {'order _ info': {" test ":" 999 qwwe ", 'A ': "sssqweee" }}} res_dict.update (update_body) res_set.append (res_dict) Success, _ = helpers. bulk (ES, actions = res_set)
elasticsearch data modification