,假设我有1000个用户,每个用户都有50个文档(每个文档嵌入具有名称和电子邮件的用户对象(,我需要为一组用户更新名称和电子邮件。p>我想使用Bulk API,但是似乎批量API仅支持" _id"作为参数。我想做一个查询
例如:我想做,
POST _bulk
{ "update" : {"query" : {"terms": {"userId": "25"}}, "_type" : "comments", "_index" : "comments"} }
{ "doc" : {"user.name" : "new name"} }
而不是
POST _bulk
{ "update" : {"_id" : "1", "_type" : "comments", "_index" : "comments"} }
{ "doc" : {"user.name" : "new name"} }
您可以使用查询API的更新为此目的:
POST comments/_update_by_query
{
"script": {
"inline": "ctx._source.user.name = newName",
"lang": "painless",
"params": {
"newName": "new name"
}
},
"query": {
"term": {
"userId": "25"
}
}
}