I am using Elasticsearch 6.5. I am writing a script for an update API in painless. I need to add structures to an array of structures. If this field does not exist in the document (I can detect that) I am creating a new array with the first element:
ctx._source.myStructArr = new def[] {struct_1};
Later I want to add additional structures:
ctx._source.myStructArr.add(struct_n);
but I receive the following error:
"type": "illegal_argument_exception",
"reason": "dynamic method [java.lang.Object[], add/1] not found"
How can I add an element to this array? Or maybe I should create/initialize an array in a different way?