Can not create script field by using regex in kibana

I want to create new script field in Kibana. I want to using regex to cut some text from another field ('message') and fill to new script field. I follow instruction link below:


( Match a string and return that match section in this link)

My code here:

def m = /^.*\.([a-z]+)$/.matcher(doc['message'].value);
if ( m.matches() ) {
   return m.group(1)
} else {
   return "no match"
}

But it didn't work.
Script is invalid. View script preview for details
and kibana mark 'matcher' as a error (red line under that text).

Can you give me some idea or solution? Thanks.

hi

One reason could be that RegExp are disabled in Elasticsearch by default.

Did you set script.painless.regex.enabled: true in elasticsearch.yml

Best,
Matthias

Thank matw very much :slight_smile:

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.