Multi-line scripts not supported like in Kibana
Closed this issue ยท 2 comments
Hi @chengpohi,
First of all, I have to say great work. I really like your plugin.
I have one issue with multi-line scripts. For maintaining long scripts is deemed necessary to use multi-line scripts for easier visualization. It would great to support multi-line scripts in the plugin. E.g following script is not supported, but works perfectly in Kibana.
POST _scripts/clean-old-profiles
{
"script": {
"lang": "painless",
"source": """
void iterateAllFields(def x) {
if (x instanceof List) {
for (def v: x) {
iterateAllFields(v);
}
}
if (!(x instanceof Map)) {
return;
}
x.entrySet().removeIf(e -> (e.getValue() == "" || e.getValue() == null || ((e.getValue() instanceof List || e.getValue() instanceof Map) && e.getValue().isEmpty())));
for (def v: x.values()) {
iterateAllFields(v);
}
}
ctx.following = null;
ctx.ims = null;
ctx.products = null;
iterateAllFields(ctx);
if (ctx.languages != null) {
for(item in ctx.languages) {
item.remove('isProfileLanguage');
}
}
if (ctx.emails != null) {
for(item in ctx.emails) {
item.remove('probability');
}
}
"""
}
}
Cool, multi-line script should be supported, I will take look at this, this will release on 1.7.3 or 1.7.4 in next week. for now I am working on refactoring the parser to better support variables
https://plugins.jetbrains.com/plugin/16364-elasticsearch-query--edql/versions
1.7.4 has released, support for triple quotes. but for now it's not support format java code in painless script. it will be supported in future version.
Thanks your feedback.