Merging two nested fields with update_by_query

Hello elastic community,

I'm trying to merge two nested fields from two different documents. The nested fields have objects inside of them.

I tried to load the nested array from the first document and add it to the nested field in the second document but have no luck. The query seems to work but nothing change in the document.

client.update_by_query index: 'event_lists', conflicts: "proceed",
                           body: {
                             "script": {"source": "
                             ArrayList events =;
                             if (ctx._id == params.to_model_id) { 
                               for(event in events) {	
                            "lang": "painless",
                            "params": {
                              to_model_id => to_model_id,
                              events => events

Here is the response I get



I am not sure I get understand request, maybe you can add a little more details. My biggest issue is, that you cannot access the values of another document in an update by query.

Can you provide a complete, but minimal example someone can copy & paste in Kibana Dev Tools including index/document creation and that update by query call?

Thank you!

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