# Creating a template to update mapping based on \_type field

**URL:** https://discuss.elastic.co/t/creating-a-template-to-update-mapping-based-on--type-field/29794
**Category:** Elasticsearch
**Created:** [September 22, 2015, 4:15pm UTC](https://discuss.elastic.co/t/creating-a-template-to-update-mapping-based-on--type-field/29794 "2015-09-22T16:15:17Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![jdepp99](https://avatars.discourse-cdn.com/v4/letter/j/58956e/32.png) [@jdepp99](https://discuss.elastic.co/u/jdepp99)
#### Post date: [September 22, 2015, 4:15pm UTC](https://discuss.elastic.co/t/creating-a-template-to-update-mapping-based-on--type-field/29794/1 "2015-09-22T16:15:17Z")

</div>

I resolved a previous issue where I wanted to update a field that was marked analyzed to mark all fields going to a specific named index to be marked as not\_analyzed. I would like to do a similar thing but on an index that is ingesting multiple types of data. The person who set this up named the sources by the \_type field and since i am responsible for one of those types, I need to ensure the visuals created show the correct fields. These are not being indexed and do not appear so is there a way to create a template to update specific indices but only that \_type (source) to include all fields to be indexed.  
For example if index [logstash]-yyyy.mm.dd has 4 different types : \_A, \_B, \_C , \_D, can a template be created to index all fields related to type \_D. They do not want to alter the /conf file to update this and suggested I use the correct queries but how must I do this if the fields are not indexed.

Any help appreciated. I included the following which I know is wrong but this is a template to only correct indices with the name logstash\* but I need to update only the \_type. Is that possible?

```
PUT /_template/fattemplate_1 
{
"template" : "logstash*",
"settings" : {
"index.refresh_interval" : "5s"
},
"mappings" : {
 "_default_" : {
 "_all" : {"enabled" : true},
 "dynamic_templates" : [ {
  "string_fields" : {
    "match" : "*",
    "match_mapping_type" : "string",
    "mapping" : {
     "type" : "string", "index" : "not_analyzed", "omit_norms" : true

     }
  }
  } ],
"properties" : {
  "@version": { "type": "string", "index": "not_analyzed" },
  "geoip" : {
  "type" : "object",
    "dynamic": true,
    "path": "full",
    "properties" : {
     "location" : { "type" : "geo_point" }
    }
    }
   }
  }
 }
 }
```

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [September 23, 2015, 2:29am UTC](https://discuss.elastic.co/t/creating-a-template-to-update-mapping-based-on--type-field/29794/2 "2015-09-23T02:29:52Z")

</div>

You can now, but from Elasticsearch 2.0 you won't be able to - [https://www.elastic.co/blog/great-mapping-refactoring](https://www.elastic.co/blog/great-mapping-refactoring)

In your example you want to add a new section like the `_default_` one with whatever type you want.

---

<div class="post-metadata">

### Author: ![jdepp99](https://avatars.discourse-cdn.com/v4/letter/j/58956e/32.png) [@jdepp99](https://discuss.elastic.co/u/jdepp99)
#### Post date: [November 17, 2015, 5:10pm UTC](https://discuss.elastic.co/t/creating-a-template-to-update-mapping-based-on--type-field/29794/3 "2015-11-17T17:10:35Z")

</div>

thanks for the response and suggestion.

---

<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, 11:37pm UTC](https://discuss.elastic.co/t/creating-a-template-to-update-mapping-based-on--type-field/29794/4 "2017-07-05T23:37:53Z")

</div>


