我想创建一个基于cs_uri_query列的脚本字段。在7.6之前,我一直使用elasticsearch 7.5,当我创建这个regex公式时,它在索引A的脚本字段中运行良好。现在我把elasticsearch升级到7.7,并把索引B加入到elasticsearch中。索引B和索引A有相同的格式(列中的所有内容都相同),所以我想使用相同的regex公式。但不幸的是,当我把索引A的脚本字段复制到索引B中时。
{
"root_cause": [
{
"type": "script_exception",
"reason": "compile error",
"script_stack": [
"... = 0) return '';\r\ndef m = /(...(?=&custid))/.matche ...",
" ^---- HERE"
],
"script": "if (doc['cs_uri_query.keyword'].size() == 0) return '';\r\ndef m = /(...(?=&custid))/.matcher(doc['cs_uri_query.keyword'].value);\r\nif(m.find () )\r\n{return m.group(1) } \r\nelse { return \"No ID\" }",
"lang": "painless",
"position": {
"offset": 65,
"start": 40,
"end": 90
}
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "janmei",
"node": "KVuYPKPBRIO-mIQu0lS3LQ",
"reason": {
"type": "script_exception",
"reason": "compile error",
"script_stack": [
"... = 0) return '';\r\ndef m = /(...(?=&custid))/.matche ...",
" ^---- HERE"
],
"script": "if (doc['cs_uri_query.keyword'].size() == 0) return '';\r\ndef m = /(...(?=&custid))/.matcher(doc['cs_uri_query.keyword'].value);\r\nif(m.find () )\r\n{return m.group(1) } \r\nelse { return \"No ID\" }",
"lang": "painless",
"position": {
"offset": 65,
"start": 40,
"end": 90
},
"caused_by": {
"type": "illegal_state_exception",
"reason": "Regexes are disabled. Set [script.painless.regex.enabled] to [true] in elasticsearch.yaml to allow them. Be careful though, regexes break out of Painless's protection against deep recursion and long loops."
}
}
}
]
}
id=000&custid=77777777&[email protected]
if (doc['cs_uri_query.keyword'].size() == 0) return '';
def m = /(...(?=&custid))/.matcher(doc['cs_uri_query.keyword'].value);
if(m.find () )
{return m.group(1) }
else { return "No ID" }
我把相同的脚本从索引A复制到索引B。谁能给我解释一下?谢谢你这么多
就像错误所说的那样。
Regexes是被禁用的,在elasticsearch.yaml中设置[script.painless.regex.enabled]为[true]允许使用。在elasticsearch.yaml中设置[script.painless.regex.enabled]为[true]以允许它们。不过要注意,regexes会脱离Painless对深度递归和长循环的保护。
你需要在弹性search.yaml中设置
script.painless.regex.enabled: true
在你 elasticsearch.yml
fiel并重新启动ES。