We have a field called access2
that is currently mapped with object (json).
Now I want to add some data to it based on some logic. I want to check the value of another field access (which is mapped to nested/array) and update the object accordingly.
E.g.
Nested field - "access": ["client": "yes"]
I want the new access2
field to contain data like -
{"production": ["client": "yes"], "nonprod": ["client": "yes"]}
I have tried below:
POST json-index/_update_by_query { "script": { "source": """ ctx._source.access2 = { "production": ctx._source.access, "nonprod": ctx._source.access } """, "lang": "painless" } }
But it is failing with below error:
"lang": "painless", "caused_by": { "type": "illegal_argument_exception", "reason": "invalid sequence of tokens near ['{'].", "caused_by": { "type": "no_viable_alt_exception", "reason": null } }
},
"status": 500