ElasticSearch search for special characters with pattern analyzer
From what you have explained what I got is that you want to do partial matches also like searching for "aterial_get".
To satisfy all your requirement, you need to change the mapping of your field to have ngram token filter in the analyzer and without removing the special characters. A sample analyzer can look like
{ "settings":{ "analysis":{ "analyzer":{ "partialmatch":{ "type":"custom", "tokenizer":"keyword", "filter":[ "lowercase", "ngram" ] } }, "filter":{ "ngram":{ "type":"ngram", "min_gram":2, "max_gram":15 } } } }}
And define in your mapping for your_field
the analyzer "partialmatch" defined above. You can change the values of min_gram
and max_gram
as per your needs.
With this mapping you can do a normal term search like below
{ "term": { "your_field": "aterial_get" }}