备注:
- _update_by_query操作只适用于es5版本以上!
**批量更新es某个字段:**
_update_by_query POST
{
"script": {
"inline": "ctx._source.statusList = params.statusList;",
"params": {
"statusList": "111"
},
"lang": "painless"
},
"query": {
"bool": {
"must": [
{
"match": {
"siteKeyId": "10052780298"
}
},
{
"match": {
"statusList": "001"
}
}
]
}
}
}
说明:
(1)该案例query部分代表即将被替换的数据集合;【替换前先查看替换的数据有哪些
】
(2)该案例params内部描述的是要替换的字段集合;
(3)该案例inline说明了原始数据的字段与替换字段的替换关系;