0

I am using ES1.4.4 and wanted to run an update script with the Update API that iterated over a ctx._source.nested_object and updated only the nested objects that fulfilled the requirements of the script. It seems relatively very simple but for some reason I am not getting an update.

script : 'for(i in ctx._source.nested_object){ if(ctx._source.nested_object[i].user.id == id){ ctx._source.nested_object[i].user = merge }  }',
params : { "id" : "SEL123" , "merge" : { "key1" : "value1" } }

All the fields that are being added/set to the new object match the field types of the existing source. Scripts are enabled in my cluster instance. The script language is Groovy.

1 Answer 1

0

Try the script:

for(i in ctx._source.nested_object){ 
    if (i.user.id == id) { 
        i.user = merge
    } 
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.