Index template creation not working

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

Hi,

You should change the template as follows

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.

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

You cannot change _all setting to already created index type.

Thanks @johtani