Hi.
I'm starting to use painless script in my ES queries and I'm currently struggled to convert a parameter or a variable to a Pattern.
GET ressources/_search
{
"query": {
"bool": {
"must": {
"script": {
"script": {
"inline": "
boolean find = false;
for( doc in params['_source']['documents']) {
Pattern patt = /params.value/;
if ( doc.label =~ /patt/ ) {
find = true;
}
} return find;",
"lang": "painless",
"params": {
"value": "title"
}
}
}
}
}
}
}
So with this script my variable patt has value "/params.value/" instead of "/title/".
I tried to use def patt = ~params.value;
like suggested in Groovy doc but it's not worked too.
Anyone as a suggestion?
Thanks !