Defining Custom analyzers globally

We have created our own custom analyzer definition based on our application-wide needs and that is quite different from available analyzers in ElasticSearch like standard or classical analyzers.

We have around 30 indices and i want to use this custom analyzer for all these indices. As much as I know and have searched, it seems that i need to include the analyzer definition in all the index definitions which seems like gross duplication of information.

Is it possible that I can define a custom analyzer once (possibly, without having to associate it's definition with any index), and then use this custom analyzer for several indices without having to redefine analyzer definition within each index definition?

1 Like

You could define an Index Template that specifies your custom analyzer. If you wanted it to apply to all indices you could define "template": "*" in the template definition.


Thanks for your reply, Colin
I would ideally like to control the analyzer at index mapping level(like the way we specify inbuilt analyzers standard, classic, etc) rather than applying my analyzer definition to all the indices. Using index templates will force me to name my indices in a particular way to have templates applied to selected indices, that's something I want to stay away from, at least for my simplistic scenario. Is there any other way to achieve this?

If you just specify the analyzer in the settings of the index template then it will just make it available to the index rather than setting it to be used so you can then reference it in your mappings when you need it.

As I mentioned before you should be able to specify the index name template as * and match all indices so your analyzer would be available on all indices (and as I mentioned above you can select in the mappings whether the index should use the analyzer and on which fields).

Thank you. It worked!