I have pipeline script that seams it works fine when I script it from Kibana, and it looks like this:
PUT _ingest/pipeline/vv_test
{
"description": "changing NaN",
"processors": [
{
"script": {
"source": """
if(ctx.snapshots != null ) {
for (int i=0; i < ctx.snapshots.size(); i++) {
List toRemove = new ArrayList();
Set keySet = ctx.snapshots[i].keySet();
for (key in keySet) {
if(ctx.snapshots[i].get(key) == 'NaN') {
toRemove.add(key)
}
}
for (int j=0; j < toRemove.size(); j++) {
ctx.snapshots[i].remove(toRemove[j]);
}
}
}
""",
"lang": "painless"
}}
]
}
If I try to use curl command to add this pipeline (or same issue is when I try to create pipeline from service using HttpURLConnection since there is no API in 6.2.4 ), I have issue with invalid JSON, which is obvious why (those 3 quotes at start and end of script source).
I just can't make it work, when I make it valid JSON by escaping quotes inside script, then I get 500 error, compile error, complaining on ".
Does anyone know what I am doing wrong? I feel if I have it solved for
curl -XPUT 'localhost:9200/_ingest/pipeline/vv_test' -H 'Content-Type: application/json' -d'
{...
}'
then I would know what should my string look like for HttpURLConnection . Or maybe not?