# Template setting some fields to not analyzed

**URL:** <https://discuss.elastic.co/t/template-setting-some-fields-to-not-analyzed/48746>\
**Category:** Elasticsearch\
**Created:** [April 28, 2016, 11:10pm UTC](https://discuss.elastic.co/t/template-setting-some-fields-to-not-analyzed/48746 "2016-04-28T23:10:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![stecino](https://avatars.discourse-cdn.com/v4/letter/s/ea666f/32.png) [@stecino](https://discuss.elastic.co/u/stecino)\
**Post date:** [April 28, 2016, 11:10pm UTC](https://discuss.elastic.co/t/template-setting-some-fields-to-not-analyzed/48746/1 "2016-04-28T23:10:14Z")

</div>

Hello,

Here is the snipped of my index mapping. It's a dynamically generated mapping, but in my template I want to be able to convert beat.hostname and [beat.name](http://beat.name) to 'not\_analyzed'. Is there a way to explicitly define this, but at the same time let everything else get assigned dynamically as it's now?

curl -XGET localhost:9200/topbeat-2016.04.28/\_mapping/filesystem?pretty  
{  
"topbeat-2016.04.28" : {  
"mappings" : {  
"filesystem" : {  
"properties" : {  
"@timestamp" : {  
"type" : "date",  
"format" : "strict\_date\_optional\_time||epoch\_millis"  
},  
"@version" : {  
"type" : "string"  
},  
"beat" : {  
"properties" : {  
"hostname" : {  
"type" : "string"  
},  
"name" : {  
"type" : "string"  
}  
}  
},  
"beatsource" : {  
"type" : "string"  
},  
"count" : {  
"type" : "long"  
},  
"dc" : {  
"type" : "string"  
},  
"fs" : {  
"properties" : {  
"avail" : {  
"type" : "long"  
},  
"device\_name" : {  
"type" : "string"  
},  
"files" : {  
"type" : "long"  
},  
"free" : {  
"type" : "long"  
},  
"free\_files" : {  
"type" : "long"  
},  
"mount\_point" : {  
"type" : "string"  
},  
"total" : {  
"type" : "long"  
},  
"used" : {  
"type" : "long"  
},  
"used\_p" : {  
"type" : "long"  
}  
}  
},  
"host" : {  
"type" : "string"  
},  
"kafka" : {  
"properties" : {  
"consumer\_group" : {  
"type" : "string"  
},  
"msg\_size" : {  
"type" : "long"  
},  
"partition" : {  
"type" : "long"  
},  
"topic" : {  
"type" : "string"  
}  
}  
},  
"platform" : {  
"type" : "string"  
},  
"tags" : {  
"type" : "string"  
},  
"type" : {  
"type" : "string"  
}  
}  
}  
}  
}  
}

---

<div class="post-metadata">

**Author:** ![MrLee](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mrlee/32/9429_2.png) [@MrLee](https://discuss.elastic.co/u/MrLee)\
**Post date:** [April 29, 2016, 3:40am UTC](https://discuss.elastic.co/t/template-setting-some-fields-to-not-analyzed/48746/2 "2016-04-29T03:40:25Z")

</div>

Just try setting like this:

```auto
curl -XPUT 'localhost:9200/_template/my_temp_name' -d '
{
        "order": 0,
        "template": "my_index_name*",
        "settings": {
            "index.number_of_shards": "5"
        },
        "mappings": {
            "_default_": {
                "dynamic_templates": [
                    {
                        "string": {
                            "mapping": {
                                "index": "not_analyzed",
                                "type": "string"
                            },
                            "match": "hostname*"
                        }
                    }
                ]
            }
        },
        "aliases": {}
    }
}
'

```

---

<div class="post-metadata">

**Author:** ![stecino](https://avatars.discourse-cdn.com/v4/letter/s/ea666f/32.png) [@stecino](https://discuss.elastic.co/u/stecino)\
**Post date:** [May 3, 2016, 4:26am UTC](https://discuss.elastic.co/t/template-setting-some-fields-to-not-analyzed/48746/3 "2016-05-03T04:26:08Z")

</div>

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:** [July 5, 2017, 10:54pm UTC](https://discuss.elastic.co/t/template-setting-some-fields-to-not-analyzed/48746/4 "2017-07-05T22:54:31Z")

</div>


