# Index template creation not working

**URL:** <https://discuss.elastic.co/t/index-template-creation-not-working/40328>\
**Category:** Elasticsearch\
**Created:** [January 28, 2016, 7:07am UTC](https://discuss.elastic.co/t/index-template-creation-not-working/40328 "2016-01-28T07:07:41Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![r.ganeshbabu](https://avatars.discourse-cdn.com/v4/letter/r/4da419/32.png) [@r.ganeshbabu](https://discuss.elastic.co/u/r.ganeshbabu)\
**Post date:** [January 28, 2016, 7:07am UTC](https://discuss.elastic.co/t/index-template-creation-not-working/40328/1 "2016-01-28T07:07:41Z")

</div>

Hi All,

I have a problem in creating index templates which seems not working for me I couldn't find where I made mistake.  
I created a sample index template with settings & new mapping as like as follows.. After that I created item\_index and indexed values and during index creation does not set the precision\_step & doc value attribute as per the item\_index\_template in the mappings. Does doc\_value & precision\_step attribute needs to be set in different manner while using templates?

PUT /\_template/item\_index\_template  
{  
"template": "item\*",  
"settings": {  
"number\_of\_shards": 20  
},  
"mappings": {  
"ICV": {  
"properties": {  
"C37": {  
"type": "long",  
"precision\_step": 2147483647,  
"doc\_values": true  
} } } } }

**Sample Item\_index**  
POST itemtest/item/3214438  
{  
"ITEM\_ID": 3214438,  
"ITEM\_CODE": "9588049",  
"ITEM\_DSCR": "HOME FURNISHINGS & DECOR",  
"ITEM\_SPECIFICITY\_REF\_ID": 186,  
"ITEM\_TYPE": "SGI",  
"HAS\_HIST\_IND": "Y",  
"MOD\_CHR\_VAL\_ID": 18136791,  
"MOD\_DSCR": "HOME FURNISHINGS & DECOR",  
"DIST": [  
{  
"RGN\_ID": 5,  
"RGN\_NM": "AT",  
"RGN\_DESC": "TEST ITEM",  
"DSTN\_STRT\_DT": "2011-03-03 21:33:51",  
"IS\_FFU\_IND": "Y",  
"FIRST\_FFU\_DT": "2012-07-06 16:17:18",  
"HAS\_LPV\_IND": "N",  
},  
],  
**"ICV": { "C37": 18136791 }**  
}

The number of shard which I given in index\_template are reflected in settings of index itemtest.

**Sample output of itemtest settings**  
"itemtest": {  
"settings": {  
"index": {  
"creation\_date": "1453962000588",  
**"number\_of\_shards": "20",**  
"analysis": {  
"filter": {  
"substring": {  
"type": "nGram",  
"min\_gram": "2",  
"max\_gram": "20"  
},

**sample output of itemtest mapping**  
"HAS\_IMAGE\_IND": {  
"type": "string",  
"index": "not\_analyzed",  
"doc\_values": true  
},  
**"ICV": { "properties": {"C37": {"type": "long"}}},**  
"IS\_SHARED\_IND": {  
"type": "string",  
"index": "not\_analyzed",  
"doc\_values": true  
},

Please let us know your suggestions.

Thanks,  
Ganeshbabu R

---

<div class="post-metadata">

**Author:** ![johtani](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/johtani/32/44956_2.png) [@johtani](https://discuss.elastic.co/u/johtani)\
**Post date:** [January 28, 2016, 7:44am UTC](https://discuss.elastic.co/t/index-template-creation-not-working/40328/2 "2016-01-28T07:44:24Z")

</div>

Hi,

You should change the template as follows

```auto
PUT /_template/item_index_template
{
"template": "item*",
"settings": {
"number_of_shards": 20
},
"mappings": {
  "item": {
  "properties": {
"ICV": {
"properties": {
"C37": {
"type": "long",
"precision_step": 2147483647,
"doc_values": true
} } } } }
}
}

```

Add "item" after "mappings", since you have "item" type.  
You have to specify "type" of index in the mappings.

---

<div class="post-metadata">

**Author:** ![r.ganeshbabu](https://avatars.discourse-cdn.com/v4/letter/r/4da419/32.png) [@r.ganeshbabu](https://discuss.elastic.co/u/r.ganeshbabu)\
**Post date:** [January 28, 2016, 8:15am UTC](https://discuss.elastic.co/t/index-template-creation-not-working/40328/3 "2016-01-28T08:15:45Z")

</div>

Thanks for your response @johtani

In my item test mapping I have given **\_all enabled false** if I try to create a new index with mapping I am getting the following error,.  
{  
"error": "RemoteTransportException[[dayrhebfmd001\_DEV\_MASTER][inet[/10.7.145.21:9300]][indices:admin/mapping/put]]; nested: MergeMappingException[Merge failed with failures {[mapper [\_all] enabled is true now encountering false]}]; ",  
"status": 400  
}

Instead of setting \_all enabled to false I changed to true and I tried indexing the mapping were appended correctly.

**How to avoid this error when \_all enabled has set to false?**

**Sample item mapping**  
PUT itemtest/item/\_mapping  
{  
"item": {  
"\_all": {  
"enabled": false  
},  
"properties": {  
"ITEM\_ID": {  
"type": "long",  
"index": "not\_analyzed",  
"doc\_values": "true",  
"norms": {  
"enabled": false  
}}}}}

Thanks  
Ganeshbabu R

---

<div class="post-metadata">

**Author:** ![johtani](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/johtani/32/44956_2.png) [@johtani](https://discuss.elastic.co/u/johtani)\
**Post date:** [January 28, 2016, 8:48am UTC](https://discuss.elastic.co/t/index-template-creation-not-working/40328/4 "2016-01-28T08:48:09Z")

</div>

You cannot change `_all` setting to already created index type.

---

<div class="post-metadata">

**Author:** ![r.ganeshbabu](https://avatars.discourse-cdn.com/v4/letter/r/4da419/32.png) [@r.ganeshbabu](https://discuss.elastic.co/u/r.ganeshbabu)\
**Post date:** [January 28, 2016, 9:27am UTC](https://discuss.elastic.co/t/index-template-creation-not-working/40328/5 "2016-01-28T09:27:59Z")

</div>

Thanks @johtani

---

<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:20pm UTC](https://discuss.elastic.co/t/index-template-creation-not-working/40328/6 "2017-07-05T23:20:51Z")

</div>


