I have a painless script that works in the console but fails in curl. The script references a nested field (event.orinal).
In the Kibana console, this statement works fine:
ctx._source.event.remove('original')
In a curl statement, I get this result:
...
"ctx._source.event.remove(original)",
" ^---- HERE"
]
...
"caused_by":{"type":"illegal_argument_exception","reason":"cannot resolve symbol [original]"}},"status":400}
We have an elastic subscription, but support has repeatedly stated that help with this is 'out of scope' because curl is not an elastic product.
Any help would be greatly appreciated.
Full cURL request and response:
curl -XPOST "https://<server>:9200/<index>/_update_by_query?conflicts=proceed" -u <creds> --cacert <certpath> -H "Content-Type: application/json" -d '
{
"script" : "ctx._source.event.remove(original)",
"query" : {
"exists": { "field": "event.original" }
}
}'
{
"error":
{
"root_cause":[
{
"type":"script_exception",
"reason":"compile error",
"script_stack":
[
"ctx._source.event.remove(original)",
" ^---- HERE"
],
"script":"ctx._source.event.remove(original)",
"lang":"painless",
"position":
{
"offset":25,
"start":0,
"end":34
}
}
],
"type":"script_exception",
"reason":"compile error",
"script_stack":
[
"ctx._source.event.remove(original)",
" ^---- HERE"
],
"script":"ctx._source.event.remove(original)",
"lang":"painless",
"position":
{
"offset":25,
"start":0,
"end":34
},
"caused_by":
{
"type":"illegal_argument_exception",
"reason":"cannot resolve symbol [original]"
}
},
"status":400
}
EDIT : Your query is running NOT working.
You will always get the following result.
Try with ingest pipeline. Here is the documentation for foreach processor of ingest pipeline.
Reference: https://discuss.elastic.co/t/ingest-processor-failure-when-accessing-nested-field/144194/2