Nested Objects Script Merge

Hey all!
Simple Question :).

I have in elastic nested field called account. Documents come from logstash which is set to doc_as_upsert: true,
how to add every new account to the nested object? Using scripts?

If so, how would one do it? I have tried indexed script but I have trouble accessing logstash fields from there, original is no problem with ctx._source, any ideas?


I am currently trying scripts like this:
"script": "if (! ctx._source.account.contains(doc['event']['account'])) { ctx._source.account.add(doc['event']['account'])}"
"script": "if (! ctx._source.account.contains(event['account'])) { ctx._source.account.add(event['account'])}"
"script": "if (! ctx._source.account.contains(params['account'])) { ctx._source.account.add(params['account'])}"

all to no avail of solving update of nested objects by adding new ones.