Elasticsearch – Analyzers in Mapping and Adding Analyzers to existing Indices

Let’s see how we can use analyzers in field mappings. All it takes is an analyzer parameter within a field mapping with the name of an analyzer.

As we can see here we are using “my_analyzer” the custom analyzer from the previous code. Now insert a data record. To test.

The above code is the query to check if the analyzer is working or not.

Adding Analyzers to existing Indices

This not just covers analyzers but also character filters, tokenizers, and token filters. We have to close the index before adding the analyzers and open up the index afterward.

Use the above code to close indices. Then add the analyzer code

After adding the new analyzer open the index.