\d
and\w
are not supported in regexp query, so you have to use[0-9]
,[a-z]
,[A-Z]
, or[a-zA-Z]
instead.In Painless Script Language which is the primary script language in Elasticsearch,
String
does not have functionreplaceAll
, you should useMatcher.replaceAll
instead, and almost all features are supported. Reference.Regular expression support is disabled by default in Elasticsearch, you should enable it by editing
elasticsearch.yml
. Add a line as below and restart your elasticsearch service:
script.painless.regex.enabled: true
If your Elasticsearch runs in cluster mode, you need update elasticsearch.yml in each node.