Updating nested fields with updateAPI

Hi all,

I have a question regarding ES Update API.
I have the following API update query, which works for this specific case:

POST regdocs/regdoc/_update_by_query
{
  "script": {
    "lang": "painless",
    "inline": "if (
ctx._source.nested[0].nested[0].nested[0].nested[0].nested[0].nested[0].references.level_1[0].external_ref_id == params.view.user
     ){ctx._source.nested[0].nested[0].nested[0].nested[0].nested[0].nested[0].references.level_1[0].internal_ref = \"it_works\"}",
  "params": {
       "view": {
            "user": "id_to_search_for"
       } 
    }
  }
}

However, I want to be able to do this search without having to specify the position of the array in which id_to_search_for will appear, as I don't know this. The depth is always the same, it's just the position I don't know.

How can I do something like ctx._source.*.references.*.external_ref_id where I dont have to specify the entry? (it could also be something along the lines of nested[_])

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