Python ES批量有bulk、streaming_bulk、update_bu_query 3种方式,个人实验update_bu_query效率最高。以其为例
1、按条件更新文档:
kibana语法
POST /rec_userinfo_v1/_update_by_query?conflicts=proceed
{
"query": {
"terms": {"uid":[470979096, 331290690]}
},
"script":{
"lang":"painless",
"inline":"ctx._source.uidstatus = params.last",
"params": {"last":6}
}
}
// 查询修改结果
GET /rec_userinfo_v1/_search
{
"query": {
"terms": {
"uid": [
470979096, 331290690
]
}
}
}
// 模糊搜索结果做条件
updateBody = {
"query": {
"query_string": {"default_field": "topic", "query": "*{}*".format(topicstr)}
},
"script": {
"inline": "ctx._source.state = params.index",