Reputation: 1135
I'm using the Elasticsearch JavaScript API.
The following script works in the sense that it runs without error:
const script = {
"lang": "painless",
"source": `
for (int i = 0; i < ctx._source.metadata.length; ++i) {
}
`,
};
But when I try and use three double quotes as in the following example:
(because my script is going to be a complex multi-line one), I modify my code to:
const script = {
"lang": "painless",
"source": `
"""
for (int i = 0; i < ctx._source.metadata.length; ++i) {
}
"""
`,
};
and then I get the following error:
"reason\":\"unexpected token ['\\"\\n for (int i = 0; i < ctx._source.metadata.length; ++i) {\\n }\\n \\"'] was expecting one of [{, ';'}].\"}},\"status\":500}"}
How do I fix this issue?
Upvotes: 0
Views: 2117
Reputation: 138327
In JavaScript, multiline strings can be done with `. There is no need for the """. The documentation you reference is not for JavaScript.
... because my script is going to be a complex multi-line one
... But your first example also shows a multiline code and that works?
Upvotes: 1