在无痛脚本中对AWS Managed ElasticSearch启用正则表达式支持 [英] Enabling regex support on AWS Managed ElasticSearch in painless scripts

查看:255
本文介绍了在无痛脚本中对AWS Managed ElasticSearch启用正则表达式支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将模板上传到我的AWS托管的ElasticSearch.

I am trying to upload templates to my AWS managed ElasticSearch.

ElasticSearch响应为500错误,抱怨我需要将script.painless.regex.enabled设置为true.我知道您不能直接编辑elasticsearch.yml文件,但是是否可以在AWS托管ES上的无痛脚本中支持正则表达式?

ElasticSearch responds with a 500 error complaining that I need to set script.painless.regex.enabled to true. I know that you cannot edit the elasticsearch.yml file directly, but is there anyway to allow for support of regex in painless scripts on AWS managed ES?

推荐答案

还没有办法在AWS ES集群下使用正则表达式.

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

您可以尝试使用StringTokenizer,如下例所示:

You can try to use StringTokenizer, as following example:

示例值:

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

无痛脚本:

{
"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();"
}
}

另外,我需要提高max_compilations_rate

also, I needed to increase max_compilations_rate

PUT /_cluster/settings
{
"transient": {
  "script.max_compilations_rate": "500/1m"
}
}

这篇关于在无痛脚本中对AWS Managed ElasticSearch启用正则表达式支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆