# How to create a index template for all type

**URL:** https://discuss.elastic.co/t/how-to-create-a-index-template-for-all-type/76950
**Category:** Elasticsearch
**Created:** [March 1, 2017, 9:11am UTC](https://discuss.elastic.co/t/how-to-create-a-index-template-for-all-type/76950 "2017-03-01T09:11:46Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Super\_L](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@Super\_L](https://discuss.elastic.co/u/Super_L)
#### Post date: [March 1, 2017, 9:11am UTC](https://discuss.elastic.co/t/how-to-create-a-index-template-for-all-type/76950/1 "2017-03-01T09:11:46Z")

</div>

Hi all  
I created a index template as following:

```json
{
    "template" : "logstash-bmwrtti-*",
    "settings" : {
        "index.refresh_interval" : "5s",
        "analysis" : {
            "tokenizer" : {
                "url_tokenizer" : {
                    "type" : "pattern",
                    "pattern" : "&"
                }
            },
            "analyzer" : {
                "url_analyzer" : {
                    "type" : "custom",
                    "tokenizer" : "url_tokenizer",
                    "filter" : ["lowercase"]
                }
            }
        }
    },
    "mappings" : {
        "_default_" : {
        	"_all": { 
                "enabled": true
            },
            "properties" : {
                "rowkey" : {
                    "type" : "text"
                },
                "dirveid" : {
                    "type" : "text",
                    "fielddata": true
                },
                "uri" : {
                    "type" : "text",
                    "analyzer" : "url_analyzer"
                },
                "reqtime" : {
                    "type" : "date",
                    "format" : "epoch_millis"
                },
                "restime" : {
                    "type" : "date",
                    "format" : "epoch_millis"
                },
                "answertime" : {
                    "type" : "integer"
                },
                "serverip" : {
                    "type" : "ip"
                },
                "adcode" : {
                    "type" : "text"
                },
                "ccplonlat" : {
                    "type" : "geo_point"
                },
                "deslonlat" : {
                    "type" : "geo_point"
                },
                "cversion" : {
                    "type" : "text"
                },
                "dversion" : {
                    "type" : "text"
                },
                "responsesize" : {
                    "type" : "integer"
                },
                "datatype" : {
                    "type" : "text"
                }
            }
        }
    }
}

```

two questions:  
1、When I run a logstash to output document to the elasticsearch, each type will be created a mapping.😓  
How to create a index template for all type?  
2、When I call the cardinality agg for field [**driveid**] , returning the [**driveid**] need set fielddata=true  
How to set the not analyzer?

PS: my es version is 5.1 .

---

<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: [March 5, 2017, 11:35pm UTC](https://discuss.elastic.co/t/how-to-create-a-index-template-for-all-type/76950/2 "2017-03-05T23:35:14Z")

</div>

`"_default_"` means that unless there is a type defined mapping, use this one. You can also use `*` in there.

For 5.X, you need to define a field as the `"type": "keyword"` for it to be not analysed.

---

<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: [April 2, 2017, 11:35pm UTC](https://discuss.elastic.co/t/how-to-create-a-index-template-for-all-type/76950/3 "2017-04-02T23:35:27Z")

</div>

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