Reputation: 338
I have a requirement to update a nested document (bulk) in the elasticsearch 5.X
Conditions
Eg: {
"hits": {
"hits": [{
"_index": "myindex",
"_id": "1",
"_source": {
"ticketdesc": [{
"groupid": 244,
"groupname": "Fire and run"
}]
}
},
{
"_index": "myindex",
"_id": "2",
"_source": {
"ticketdesc": [{
"groupid": 244,
"groupname": "Fire and run"
}]
}
},
{
"_index": "myindex",
"_id": "3",
"_source": {
"ticketdesc": [{
"groupid": 244,
"groupname": "Fire and run"
}]
}
},
{
"_index": "myindex",
"_id": "4",
"_source": {
"ticketdesc": [{
"groupid": 245,
"groupname": "Fire and run"
}]
}
}
]
}
}
Thanks in advance
Upvotes: 0
Views: 83
Reputation: 217564
You can do so easily with the update by query API
POST myindex/_update_by_query
{
"query": {
"term": {"groupid": 245}
},
"script": {
"source": "ctx._source.groupname = 'New name' "
}
}
Upvotes: 1