Painless forEach + Replace failing

Hi guys,

I'm trying to write a script within watcher that applies a transform to each log before sending it through slack. My current script is like this:

        "script": {
          "source": """
                ctx.payload.hits.hits.forEach(hit -> hit._source.python_log_message = \a\.matcher(hit._source.python_log_message).replaceAll(''));
                return ctx.payload
                """,
          "lang": "painless"
        }

For some reason, it is erroring out, but i'm using the examples in the painless guide. Any reason why this would not work? It works perfectly if I, for example, do this:

        "script": {
          "source": """
                ctx.payload.hits.hits.forEach(hit -> hit._source.python_log_message =  'hello');
                return ctx.payload
                """,
          "lang": "painless"
        }

Hi

Did you enable Regular expressions by using script.painless.regex.enabled: true in your elasticsearch.yml?

Best,
Matthias

Thanks, that worked! It would probably be a good feature to warn the user that the reason why regex operators are not working is because of disabled configs, not syntax errors.