# Custom analyzers used across index templates

**URL:** https://discuss.elastic.co/t/custom-analyzers-used-across-index-templates/83282
**Category:** Elasticsearch
**Created:** [April 22, 2017, 2:24pm UTC](https://discuss.elastic.co/t/custom-analyzers-used-across-index-templates/83282 "2017-04-22T14:24:51Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![saurshah](https://avatars.discourse-cdn.com/v4/letter/s/50afbb/32.png) [@saurshah](https://discuss.elastic.co/u/saurshah)
#### Post date: [April 22, 2017, 2:24pm UTC](https://discuss.elastic.co/t/custom-analyzers-used-across-index-templates/83282/1 "2017-04-22T14:24:52Z")

</div>

So I am trying to create a custom analyzer that I can use in multiple template definition so I can use the same custom analyzer one across multiple indices. I am using Elasticsearch 2.4 and I run into an error of type 'mapper\_parsing\_exception' with message 'analyzer [my\_text\_analyzer] not found for field [test\_name]'

What I am trying to achieve looks something as follows in terms of code

```
PUT /_template/common_template

{
  "template": "*",
  "order": 0,
  "settings": {
    "analysis": {
      "analyzer": {
        "my_text_analyzer": {
          "type": "custom",
          "char_filter": ["html_strip"],
          "tokenizer": "standard",
          "filter": ["standard", "lowercase"]            
        }
      }
    }
  }
}

PUT /_template/test_template
{
  "template": "test*",
  "order": 1,
  "settings": {
    "number_of_shards": 2,
    "number_of_replicas": 2
  },
  "mappings": {
    "structure": {
      "properties": {
        "test_name" : {
          "type": "string",
          "analyzer": "my_text_analyzer"
        }
      }
    }
  }
}

```

Is there a way to achieve this?

I need to create multiple families of indices (individual index template for each family) which need to use the same custom analyzer for string fields however they all use different kinds of type mappings making it very difficult to define it all in a single template.

---

<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: [May 20, 2017, 2:29pm UTC](https://discuss.elastic.co/t/custom-analyzers-used-across-index-templates/83282/2 "2017-05-20T14:29:17Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
