# Create template is failing - "Could not resolve host:localhost"

**URL:** <https://discuss.elastic.co/t/create-template-is-failing-could-not-resolve-host-localhost/58770>\
**Category:** Elasticsearch\
**Created:** [August 24, 2016, 6:35am UTC](https://discuss.elastic.co/t/create-template-is-failing-could-not-resolve-host-localhost/58770 "2016-08-24T06:35:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Denis\_Wessels](https://avatars.discourse-cdn.com/v4/letter/d/2bfe46/32.png) [@Denis\_Wessels](https://discuss.elastic.co/u/Denis_Wessels)\
**Post date:** [August 24, 2016, 6:35am UTC](https://discuss.elastic.co/t/create-template-is-failing-could-not-resolve-host-localhost/58770/1 "2016-08-24T06:35:25Z")

</div>

I use elastic search for logging.Eevery day I have a new log index automatically created, the pattern for the name of the index is "log-\*".

I have a property in this index called Message which is being split into multiple words when I try view it in Kibana.The solution seems to be that I need to set this field to _not\_analyzed_ but seems like this is harder than it looks.

I created a .bat file which contains a template which is supposed to set Messge to not\_analyzed but when I try execute the batch file in cmd I get the following error:

![](https://us1.discourse-cdn.com/elastic/original/2X/3/3d5848035b3c054721b4fdb2b1c2daf09ea05904.PNG)

**And here is my .bat file:**

curl -XPUT 'localhost:9200/\_template/template\_1' -d '{  
"template": "log-_",  
"settings": {  
"index.refresh\_interval": "5s"  
},  
"mappings": {  
"default": {  
"\_all": {  
"enabled": true  
},  
"dynamic\_templates": [  
{  
"string\_fields": {  
"match": "_",  
"match\_mapping\_type": "string",  
"mapping": {  
"index": "not\_analyzed",  
"omit\_norms": true,  
"type": "string"  
}  
}  
}  
],  
"properties": {  
"@Message": {  
"type": "string",  
"index": "not\_analyzed"  
},  
"geoip": {  
"type": "object",  
"dynamic": true,  
"path": "full",  
"properties": {  
"location": {  
"type": "geo\_point"  
}  
}  
}  
}  
}  
}  
}'

pause

* * *

Please help me guys, I'm struggling with this for almost a week now, what I want is really simple:

1. For all old and new templates starting with "log-\*"
2. Make sure that the Message field is set to _not\_analyzed_

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [August 24, 2016, 6:49am UTC](https://discuss.elastic.co/t/create-template-is-failing-could-not-resolve-host-localhost/58770/2 "2016-08-24T06:49:56Z")

</div>

Please don't post screenshots. Use copy/paste.

It looks like the quote right before "localhost" isn't a regular straight single quote so it's passed verbatim to curl that thinks it's part of the hostname.

But there are no command interpreter metacharacters in "localhost:9200/\_template/template\_1" so you can just drop the quotes around it.

Secondly, I don't think Windows's command interpreter supports this kind of multi-line arguments (so it thinks each line a new command that it can't recognize). As I suggested earlier you might be better served by Sense, Postman, or some other browser plugin for making REST calls.

> 1. For all old and new templates starting with "log-\*"

If you had just gone with the default index name pattern of logstash-\* you wouldn't have had these problems. A good rule of thumb is to stick to defaults for a while.

---

<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:25pm UTC](https://discuss.elastic.co/t/create-template-is-failing-could-not-resolve-host-localhost/58770/3 "2017-07-05T22:25:42Z")

</div>


