so here is the thing , i have this long script that define variables of type
String[] words_var1 = new String[] {'word1','word1','word1'}
then i have this function that tries to assign the right word to the right doc based on an id like so
def addwords(id, words) {
if (ctx._source.fiiled1.contains(id)) {
if (ctx._source.fiiled2 == null) {
ctx._source.fiiled2 = [];
}
ctx._source.fiiled2.addAll(Arrays.asList(words));
}
};
addwords(1, words_var1);
i'm not even sure what the error that i get mean and i can't find it cause the script is too long ,
"script_stack": [
"""... def addwords(id, words) {
if ...""",
" ^---- HERE"
],
"caused_by": {
"type": "illegal_argument_exception",
"reason": "unexpected token ['('] was expecting one of [{<EOF>, ';'}]."
}
so i never wrote painless before and i really can't find good examples about so don't go hard on me as i suspect that not the way to even define a function