In painless script, i tried passing a variable which stringifies a json object, like this:
let sourcedData = JSON.stringify(body)
body: {
lang: 'painless',
script: 'if (ctx._source.files == null) { ctx._source.files = params.object } else { ctx._source.files.add(params.object) }'
params: {
object: sourcedData
}
},
id,
index,
refresh: true,
type: DocType
}).catch(logAndRethrow)
Although it does not produce any error, but the field files
is null, Is there any way we can pass these kinds of variables within painless?