# How to update multiple nested objects?

**URL:** <https://discuss.elastic.co/t/how-to-update-multiple-nested-objects/197837>\
**Category:** Elasticsearch\
**Tags:** painless\
**Created:** [September 3, 2019, 11:37am UTC](https://discuss.elastic.co/t/how-to-update-multiple-nested-objects/197837 "2019-09-03T11:37:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bidzina\_Goginashvili](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bidzina_goginashvili/32/51114_2.png) [@Bidzina\_Goginashvili](https://discuss.elastic.co/u/Bidzina_Goginashvili)\
**Post date:** [September 3, 2019, 11:37am UTC](https://discuss.elastic.co/t/how-to-update-multiple-nested-objects/197837/1 "2019-09-03T11:37:35Z")

</div>

My Mapping looks like this..What i want to do is that when i delete category with Id 9 this element should be deleted from every products...

> ```
> {
> "_index" : "onoff-products-main2",
> "_type" : "_doc",
> "_id" : "177",
> "_score" : 1.0,
> "_source" : {
> "name" : "Alcatel A3 XL 8GB White [9008D]",
> "shortDescription" : "ოპერატიული მეხსიერება 1 GB, ფლეშ-მეხსიერება 8 GB, 2 SIM, თეთრი",
> "fullDescription" : "<p>Android, ეკრანი 6\" IPS (720x1280), Mediatek MT8735, ოპერატიული მეხსიერება 1 GB, ფლეშ-მეხსიერება 8 GB, ბარათის მეხსიერება, კამერა 8 MP, ბატარეა 3000 mAh, 2 SIM, ფერი თეთრი</p>",
> "sku" : "177",
> "vendorMinPrice" : 0.0,
> "vendorMaxPrice" : 0.0,
> "published" : true,
> "parentBaseProductId" : 0,
> "avarageRating" : 0,
> "createdDate" : "2018-10-22T11:57:49.1100000",
> "modelName" : "A3 XL",
> "viewStatistics" : 328,
> "deleted" : false,
> "categories" : [
> {
> "id" : 9
> }
> ],
> 
> ```
> 
> }

---

<div class="post-metadata">

**Author:** ![Bidzina\_Goginashvili](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bidzina_goginashvili/32/51114_2.png) [@Bidzina\_Goginashvili](https://discuss.elastic.co/u/Bidzina_Goginashvili)\
**Post date:** [September 3, 2019, 11:42am UTC](https://discuss.elastic.co/t/how-to-update-multiple-nested-objects/197837/2 "2019-09-03T11:42:48Z")

</div>

> POST onoff-products-main2/\_update\_by\_query  
> {
> 
> ```
> "script" : "ctx._source.categories.removeAll{it.id == remove_id}",
> "params": {
> "remove_id" : 9
> }
> 
> ```
> 
> }  
> i am trying this

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [September 4, 2019, 8:02am UTC](https://discuss.elastic.co/t/how-to-update-multiple-nested-objects/197837/3 "2019-09-04T08:02:12Z")

</div>

can you contain a fully fledged minimal example for others to reproduce as well as error message that are returned. See [https://www.elastic.co/help](https://www.elastic.co/help)

That said, I think you are searching for `removeIf` instead of `removeAll`...

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 2, 2019, 8:02am UTC](https://discuss.elastic.co/t/how-to-update-multiple-nested-objects/197837/4 "2019-10-02T08:02:15Z")

</div>

Closed on October 2, 2019, 8:02am UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
