I have a requirement to update document (bulk) in the elasticsearch 5.X
Conditions
I have to update them in bulk.
{ "hits": [{ "_index": "myindex", "_id": "1", "_source": { "TicketSet": [{ "Tasks": [{ "Group": { "Id": 245, "Name": "Name 245" } }, { "Group": { "Id": 244, "Name": "Name 244" } }] }] } }, { "_index": "myindex", "_id": "3", "_source": { "TicketSet": [{ "Tasks": [{ "Group": { "Id": 245, "Name": "Name 245" } }, { "Group": { "Id": 244, "Name": "Name 244" } }] }] } }]
}
You can do so easily with the update by query API (I made the assumption that ticketdesc
is nested
):
POST tickets/_update_by_query
{
"query": {
"term": {
"TicketSet.Tasks.Group.Id": 245
}
},
"script": {
"inline": "ctx._source.TicketSet[0].Tasks.stream().filter(g -> g.Group.Id == params.groupId).forEach(g -> g.Group.Name = params.newName)",
"params": {
"groupId": 245,
"newName": "New name"
}
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.