# Error when creating a template

**URL:** <https://discuss.elastic.co/t/error-when-creating-a-template/49871>\
**Category:** Elasticsearch\
**Created:** [May 12, 2016, 9:03am UTC](https://discuss.elastic.co/t/error-when-creating-a-template/49871 "2016-05-12T09:03:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Giulio](https://avatars.discourse-cdn.com/v4/letter/g/45deac/32.png) [@Giulio](https://discuss.elastic.co/u/Giulio)\
**Post date:** [May 12, 2016, 9:03am UTC](https://discuss.elastic.co/t/error-when-creating-a-template/49871/1 "2016-05-12T09:03:11Z")

</div>

Hi  
I have a problem when I create a new template.  
As I wrote in the previous post I must create a simple template whit a different tokenizer because the standard one delete some character that I need.

so I create this one:

{  
"template": "apache\_access-\*",  
"order": 1,  
"settings": {  
"number\_of\_shards": 3,  
"number\_of\_replicas": 1  
},  
"analysis": {  
"my\_analyzer": {  
"type": "custom",  
"filter": "standard",  
"tokenizer": "whitespace"  
}  
},  
"mappings": {  
"referer": {"type": "string"},  
"request": {"type": "string"},  
"auth": {"type": "string"},  
"sslClient": {"type": "string"},  
"type": {"type": "string"},  
"path": {"type": "string"},  
"pathFolder": {"type": "string"},  
"sslProt": {"type": "string"},  
"httpVersion": {"type": "string"},  
"bSent": {"type": "long"},  
"clientIP": {"type": "string"},  
"@version": {"type": "string"},  
"host": {"type": "string"},  
"connection": {"type": "string"},  
"uniqueID": {"type": "string"},  
"timestamp": {"type": "string"},  
"chiper": {"type": "string"},  
"keepAlive": {"type": "long"},  
"query": {"type": "string"},  
"@timestamp": {  
"format": "strict\_date\_optional\_time||epoch\_millis",  
"type": "date"  
},  
"response": {"type": "long"},  
"header": {"type": "string"},  
"rBytes": {"type": "long"},  
"bReceived": {"type": "long"},  
"status": {"type": "string"}  
}  
}

Elasticsearch accept this template but when I try to check it using the command

-XGET localhost:9200/\_template/?pretty=true

I receive back this error

{  
"error" : {  
"root\_cause" : [ {  
"type" : "class\_cast\_exception",  
"reason" : "java.lang.String cannot be cast to java.util.Map"  
} ],  
"type" : "class\_cast\_exception",  
"reason" : "java.lang.String cannot be cast to java.util.Map"  
},  
"status" : 500  
}

When I remove it

curl -XDELETE localhost:9200/\_template/apache

The \_template command works again

Maybe, like always is a stupid question but i can't understand why this happen!

---

<div class="post-metadata">

**Author:** ![MarkOStewart](https://avatars.discourse-cdn.com/v4/letter/m/898d66/32.png) [@MarkOStewart](https://discuss.elastic.co/u/MarkOStewart)\
**Post date:** [May 12, 2016, 4:36pm UTC](https://discuss.elastic.co/t/error-when-creating-a-template/49871/2 "2016-05-12T16:36:10Z")

</div>

Can you create other Templates?

I would take out half or more of the mapping and create the template again. Then see if you can check it. If it works add more lines of code back in until it breaks.

Likewise if it breaks on the first test try another part until you isolate the offending code.

Possible that Java is not up to date?

---

<div class="post-metadata">

**Author:** ![Giulio](https://avatars.discourse-cdn.com/v4/letter/g/45deac/32.png) [@Giulio](https://discuss.elastic.co/u/Giulio)\
**Post date:** [May 13, 2016, 8:08am UTC](https://discuss.elastic.co/t/error-when-creating-a-template/49871/3 "2016-05-13T08:08:02Z")

</div>

Hi and thank you for your reply.

Yes, I have other template for other type of data and they work without any problems.  
As you suggest I will try to create the template "step by step" adding a new element each time.

Java is update at last version, otherwise I suppose that I will receive back an error also for the other 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:** [July 5, 2017, 10:51pm UTC](https://discuss.elastic.co/t/error-when-creating-a-template/49871/4 "2017-07-05T22:51:54Z")

</div>


