Enabling regex support on AWS Managed ElasticSearch in painless scripts

ε祈祈猫儿з 提交于 2019-12-05 06:03:33

There is no way yet to use regex under AWS ES cluster.

You can try to use StringTokenizer, as following example:

example value:

doc['your_str_field.keyword'].value = '{"xxx":"123213","yyy":"123213","zzz":"123213"}'

Painless script:

{
"script": {
"lang": "painless",
"inline": "String xxx = doc['your_str_field.keyword'].value; xxx = xxx.replace('{','').replace('}','').replace('\"','').replace(' ','');StringTokenizer tokenizer = new StringTokenizer(xxx, ',');tokenizer.nextToken();tokenizer.nextToken();StringTokenizer tokenizer_v = new StringTokenizer(tokenizer.nextToken(),':');tokenizer_v.nextToken();return tokenizer_v.nextToken();"
}
}

also, I needed to increase max_compilations_rate

PUT /_cluster/settings
{
"transient": {
  "script.max_compilations_rate": "500/1m"
}
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!