# Unable to create template with Analyzer

**URL:** <https://discuss.elastic.co/t/unable-to-create-template-with-analyzer/124708>\
**Category:** Elasticsearch\
**Created:** [March 20, 2018, 8:56am UTC](https://discuss.elastic.co/t/unable-to-create-template-with-analyzer/124708 "2018-03-20T08:56:19Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![madeti](https://avatars.discourse-cdn.com/v4/letter/m/a9a28c/32.png) [@madeti](https://discuss.elastic.co/u/madeti)\
**Post date:** [March 20, 2018, 8:56am UTC](https://discuss.elastic.co/t/unable-to-create-template-with-analyzer/124708/1 "2018-03-20T08:56:19Z")

</div>

Hello,

I was able to create an analyzer and use it on a single Index. Now, I would like to apply this to an Index template, so that whenever a new index (with Date attached to it) is created, this analyzer can be applied.

When trying to create the template it is giving me an error. Clearly something I am doing is not correct, but just could not figure out what..

```
PUT _template/textstrings

{
  "index_patterns": ["*event.abc.v1*"],
"settings": {
  "index": {
    "analysis": {
      "filter": {
        "ngram_filter": {
          "type": "nGram",
          "min_gram": "3",
          "max_gram": "20"
        }
      },
      "analyzer": {
        "title_analyzer": {
	          "type" : "custom",
	          "tokenizer": "standard",
          "filter": ["ngram_filter"]
        }
      }
    }
  }
},
"mappings": {
  "doc": {
    "properties": {
      "content": {
        "properties": {
          "title": {
            "type": "text",
            "analyzer": "title_analyzer"
          }
        }
      }
    }
  }
}
}

```

The error I receive is the following:

```
{
  "error": {
    "root_cause": [
      {
        "type": "not_x_content_exception",
        "reason": "Compressor detection can only be called on some xcontent bytes or compressed xcontent bytes"
      }
    ],
    "type": "not_x_content_exception",
    "reason": "Compressor detection can only be called on some xcontent bytes or compressed xcontent bytes"
  },
  "status": 500
}

```

Thanks to take a look.

Best regards

---

<div class="post-metadata">

**Author:** ![madeti](https://avatars.discourse-cdn.com/v4/letter/m/a9a28c/32.png) [@madeti](https://discuss.elastic.co/u/madeti)\
**Post date:** [March 22, 2018, 1:16pm UTC](https://discuss.elastic.co/t/unable-to-create-template-with-analyzer/124708/2 "2018-03-22T13:16:26Z")

</div>

Hello ... any possible help here ?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 22, 2018, 1:40pm UTC](https://discuss.elastic.co/t/unable-to-create-template-with-analyzer/124708/3 "2018-03-22T13:40:15Z")

</div>

You have a blank line been the `PUT _template` and the json. Which makes it fail I think.

This works well on my end:

```auto
PUT _template/textstrings
{
  "index_patterns": ["*event.abc.v1*"],
"settings": {
  "index": {
    "analysis": {
      "filter": {
        "ngram_filter": {
          "type": "nGram",
          "min_gram": "3",
          "max_gram": "20"
        }
      },
      "analyzer": {
        "title_analyzer": {
	          "type" : "custom",
	          "tokenizer": "standard",
          "filter": ["ngram_filter"]
        }
      }
    }
  }
},
"mappings": {
  "doc": {
    "properties": {
      "content": {
        "properties": {
          "title": {
            "type": "text",
            "analyzer": "title_analyzer"
          }
        }
      }
    }
  }
}
}

```

---

<div class="post-metadata">

**Author:** ![madeti](https://avatars.discourse-cdn.com/v4/letter/m/a9a28c/32.png) [@madeti](https://discuss.elastic.co/u/madeti)\
**Post date:** [March 22, 2018, 3:44pm UTC](https://discuss.elastic.co/t/unable-to-create-template-with-analyzer/124708/4 "2018-03-22T15:44:31Z")

</div>

Thanks a lot. Looks like it was an issue. Once I have removed the space, it fails with a different error:

```
    {
  "error": {
    "root_cause": [
      {
        "type": "action_request_validation_exception",
        "reason": "Validation Failed: 1: template is missing;"
      }
    ],
    "type": "action_request_validation_exception",
    "reason": "Validation Failed: 1: template is missing;"
  },
  "status": 400
}

```

Strange that it has worked on your end. I have checked the text and is the same. So, not sure what is missing

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 22, 2018, 7:11pm UTC](https://discuss.elastic.co/t/unable-to-create-template-with-analyzer/124708/5 "2018-03-22T19:11:48Z")

</div>

Probably you are using a 5.x version

---

<div class="post-metadata">

**Author:** ![madeti](https://avatars.discourse-cdn.com/v4/letter/m/a9a28c/32.png) [@madeti](https://discuss.elastic.co/u/madeti)\
**Post date:** [March 22, 2018, 8:10pm UTC](https://discuss.elastic.co/t/unable-to-create-template-with-analyzer/124708/6 "2018-03-22T20:10:24Z")

</div>

Yes. I am using version 5.6 version.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 22, 2018, 10:08pm UTC](https://discuss.elastic.co/t/unable-to-create-template-with-analyzer/124708/7 "2018-03-22T22:08:00Z")

</div>

So read the docs for your version: [https://www.elastic.co/guide/en/elasticsearch/reference/5.6/indices-templates.html](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/indices-templates.html)

---

<div class="post-metadata">

**Author:** ![madeti](https://avatars.discourse-cdn.com/v4/letter/m/a9a28c/32.png) [@madeti](https://discuss.elastic.co/u/madeti)\
**Post date:** [March 23, 2018, 8:52am UTC](https://discuss.elastic.co/t/unable-to-create-template-with-analyzer/124708/8 "2018-03-23T08:52:28Z")

</div>

Thanks a lot David. My bad on that. I have tried so many combinations before posting the issue here, that I forgot that I might have used the syntax of other versions.

It works now.

Thanks for your help.

---

<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:** [April 20, 2018, 8:52am UTC](https://discuss.elastic.co/t/unable-to-create-template-with-analyzer/124708/9 "2018-04-20T08:52:44Z")

</div>

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