Nov 10, 2020
Elasticsearch ingest pipeline script processor error with triple quotes
As https://discuss.elastic.co/t/pipeline-processor-script-error/149508 talks about, I meet same bug.
Once I type my script on kibana web “left top buttom”->“Stack Management”->“Ingest Node Pipelines”->”Create pipeline”:
[
{
"script": {
"source": """
if (ctx.status == "stopped") {
ctx.status = "0"
}
if (ctx.status == "running") {
ctx.status = "1"
}
"""
}
}
]
and I get following response:
The input is not valid.
After I survey lots of websites, I realize that is a bug with Kibana…
So, I change the script to write all codes in one line, and it works:
[
{
"script": {
"source": "if (ctx.status == 'stopped') {ctx.status = '0';} if (ctx.status == 'running') {ctx.status = '1';}"
}
}
]or [
{
"script": {
"source": "if (ctx.status == 'stopped') ctx.status = '0'; if (ctx.status == 'running') ctx.status = '1';"
}
}
]
Or, It seems works when send post with triple quotes to elasticsearch.
Hope this article can help you~