Hi all, I'm trying to use scripted fields and all examples from the article result in a compile error. (Examples are in sub-thread). Is there anything I am missing? Feel free to re-direct me to another channel, if this is the wrong one for this question
for example
def m = /^.*\.([a-z]+)$/.matcher(doc['host.keyword'].value);
if ( m.matches() ) {
return m.group(1)
} else {
return "no match"
}
results in
"root_cause": [
{
"type": "script_exception",
"reason": "compile error",
"script_stack": [
"def m = /^.*\\.([a-z]+)$/.matcher( ...",
" ^---- HERE"
],
"script": "def m = /^.*\\.([a-z]+)$/.matcher(doc['host.keyword'].value);\nif ( m.matches() ) {\n return m.group(1)\n} else {\n return \"no match\"\n}",
"lang": "painless"
},
Any ideas where to dig?