# Unable to get a template to apply to my index

**URL:** <https://discuss.elastic.co/t/unable-to-get-a-template-to-apply-to-my-index/118136>\
**Category:** Elasticsearch\
**Created:** [February 2, 2018, 1:16am UTC](https://discuss.elastic.co/t/unable-to-get-a-template-to-apply-to-my-index/118136 "2018-02-02T01:16:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bah7303](https://avatars.discourse-cdn.com/v4/letter/b/e47c2d/32.png) [@bah7303](https://discuss.elastic.co/u/bah7303)\
**Post date:** [February 2, 2018, 1:16am UTC](https://discuss.elastic.co/t/unable-to-get-a-template-to-apply-to-my-index/118136/1 "2018-02-02T01:16:59Z")

</div>

I am having trouble getting my template to apply and am wondering if its because we are using logstash. I am applying the template below and then recreating my index via logstash.

My template is as follows:

PUT /\_template/template\_defendant  
{  
"template": "logstash-cns-defendant-v\*",  
"settings": { "number\_of\_shards": 1 },  
"analysis": {  
"analyzer": {  
"cns\_name\_match\_analyzer" : {  
"tokenizer" : "standard",  
"filter" : ["standard", "lowercase", "stop", "porter\_stem"],  
"stopwords": ["co", "company", "llc", "corporation", "corp"]  
}  
}  
},  
"mappings": {  
"_default_": {  
"\_all": {  
"enabled": false  
},  
"dynamic\_templates": [  
{  
"strings": {  
"match\_mapping\_type": "string",  
"mapping": {  
"type": "string",  
"analyzer" : "cns\_name\_match\_analyzer",  
"fields": {  
"raw": {  
"type": "string",  
"index": "not\_analyzed",  
"ignore\_above": 256  
}  
}  
}  
}  
}  
]  
}  
}  
}

Here is the template from a GET:

GET \_template  
{  
"logstash": {  
"order": 0,  
"version": 50001,  
"template": "logstash-_",  
"settings": {  
"index": {  
"refresh\_interval": "5s"  
}  
},  
"mappings": {  
"default": {  
"\_all": {  
"enabled": true,  
"norms": false  
},  
"dynamic\_templates": [  
{  
"message\_field": {  
"path\_match": "message",  
"match\_mapping\_type": "string",  
"mapping": {  
"type": "text",  
"norms": false  
}  
}  
},  
{  
"string\_fields": {  
"match": "_",  
"match\_mapping\_type": "string",  
"mapping": {  
"type": "text",  
"norms": false,  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
}  
}  
}  
}  
],  
"properties": {  
"@timestamp": {  
"type": "date",  
"include\_in\_all": false  
},  
"@version": {  
"type": "keyword",  
"include\_in\_all": false  
},  
"geoip": {  
"dynamic": true,  
"properties": {  
"ip": {  
"type": "ip"  
},  
"location": {  
"type": "geo\_point"  
},  
"latitude": {  
"type": "half\_float"  
},  
"longitude": {  
"type": "half\_float"  
}  
}  
}  
}  
}  
},  
"aliases": {}  
},  
"template\_defendant": {  
"order": 0,  
"template": "logstash-cns-defendant-v\*",  
"settings": {  
"index": {  
"number\_of\_shards": "1"  
}  
},  
"mappings": {  
"_default_": {  
"\_all": {  
"enabled": false  
},  
"dynamic\_templates": [  
{  
"strings": {  
"match\_mapping\_type": "string",  
"mapping": {  
"type": "string",  
"analyzer": "cns\_name\_match\_analyzer",  
"fields": {  
"raw": {  
"type": "string",  
"index": "not\_analyzed",  
"ignore\_above": 256  
}  
}  
}  
}  
}  
]  
}  
},  
"aliases": {}  
}  
}

I think according to where I got the template code ([https://qbox.io/blog/set-analyzers-datatypes-default-mappings-elasticsearch](https://qbox.io/blog/set-analyzers-datatypes-default-mappings-elasticsearch)) that I should haw a column called .raw and any string columns should have the analyzer i have defined attached. I am thining i may have to create the template in logstash since i see it the the template on the index but I am not sure. Any guidance would be greatly appreciated.

Thanks!

---

<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:** [March 2, 2018, 1:17am UTC](https://discuss.elastic.co/t/unable-to-get-a-template-to-apply-to-my-index/118136/2 "2018-03-02T01:17:06Z")

</div>

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