How to update multiple nested objects?

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
        }
      ],

}

POST onoff-products-main2/_update_by_query
{

"script" : "ctx._source.categories.removeAll{it.id == remove_id}",
"params": {
    "remove_id" : 9
}

}
i am trying this

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

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

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