How to create and add nested object into nested field in Elasticsearch?
https://www.elastic.co/guide/en/elasticsearch/reference/5.4/modules-scripting-painless-syntax.html#painless-maps
You can create a map like ['first': 'Foo', 'last': 'Bar', 'sthElse': 100]
then add it.
So:
ctx._source.user.add([
"first" : "Foo",
"last" : "Bar"
])
Please note that map in painless can be mixed type.