# Defining Custom analyzers globally

**URL:** <https://discuss.elastic.co/t/defining-custom-analyzers-globally/27826>\
**Category:** Elasticsearch\
**Created:** [August 21, 2015, 9:40am UTC](https://discuss.elastic.co/t/defining-custom-analyzers-globally/27826 "2015-08-21T09:40:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![pavang6](https://avatars.discourse-cdn.com/v4/letter/p/a6a055/32.png) [@pavang6](https://discuss.elastic.co/u/pavang6)\
**Post date:** [August 21, 2015, 9:40am UTC](https://discuss.elastic.co/t/defining-custom-analyzers-globally/27826/1 "2015-08-21T09:40:13Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![colings86](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/colings86/32/44960_2.png) [@colings86](https://discuss.elastic.co/u/colings86)\
**Post date:** [August 21, 2015, 9:49am UTC](https://discuss.elastic.co/t/defining-custom-analyzers-globally/27826/2 "2015-08-21T09:49:58Z")

</div>

You could define an [Index Template](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html) that specifies your custom analyzer. If you wanted it to apply to all indices you could define `"template": "*"` in the template definition.

HTH

---

<div class="post-metadata">

**Author:** ![pavang6](https://avatars.discourse-cdn.com/v4/letter/p/a6a055/32.png) [@pavang6](https://discuss.elastic.co/u/pavang6)\
**Post date:** [August 21, 2015, 11:38am UTC](https://discuss.elastic.co/t/defining-custom-analyzers-globally/27826/3 "2015-08-21T11:38:48Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![colings86](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/colings86/32/44960_2.png) [@colings86](https://discuss.elastic.co/u/colings86)\
**Post date:** [August 21, 2015, 11:48am UTC](https://discuss.elastic.co/t/defining-custom-analyzers-globally/27826/4 "2015-08-21T11:48:05Z")

</div>

> [@pavang6](#):
>
> 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.

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.

> [@pavang6](#):
>
> 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

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).

---

<div class="post-metadata">

**Author:** ![pavang6](https://avatars.discourse-cdn.com/v4/letter/p/a6a055/32.png) [@pavang6](https://discuss.elastic.co/u/pavang6)\
**Post date:** [August 26, 2015, 11:58am UTC](https://discuss.elastic.co/t/defining-custom-analyzers-globally/27826/5 "2015-08-26T11:58:26Z")

</div>

Thank you. It worked!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 11:53pm UTC](https://discuss.elastic.co/t/defining-custom-analyzers-globally/27826/6 "2017-07-05T23:53:52Z")

</div>


