Pattern Replace Char Filter

edit

The pattern_replace char filter allows the use of a regex to manipulate the characters in a string before analysis. The regular expression is defined using the pattern parameter, and the replacement string can be provided using the replacement parameter (supporting referencing the original text, as explained here). For more information check the lucene documentation

Here is a sample configuration:

{
    "index" : {
        "analysis" : {
            "char_filter" : {
                "my_pattern":{
                    "type":"pattern_replace",
                    "pattern":"sample(.*)",
                    "replacement":"replacedSample $1"
                }
            },
            "analyzer" : {
                "custom_with_char_filter" : {
                    "tokenizer" : "standard",
                    "char_filter" : ["my_pattern"]
                },
            }
        }
    }
}