# Default mapping confusion

**URL:** <https://discuss.elastic.co/t/default-mapping-confusion/4399>\
**Category:** Elasticsearch\
**Created:** [May 13, 2011, 3:57pm UTC](https://discuss.elastic.co/t/default-mapping-confusion/4399 "2011-05-13T15:57:14Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Greg](https://avatars.discourse-cdn.com/v4/letter/g/71c47a/32.png) [@Greg](https://discuss.elastic.co/u/Greg)\
**Post date:** [May 13, 2011, 3:57pm UTC](https://discuss.elastic.co/t/default-mapping-confusion/4399/1 "2011-05-13T15:57:14Z")

</div>

Hi all

I have read through the documentation, but am slightly confused by the  
topic of default mapping.

Is there a difference between defining config/mappings/\_default/  
mapping.json as described here[1] and defining config/default-  
mapping.json as described here[2]?

Many thanks  
Greg

[1] [http://www.elasticsearch.org/guide/reference/mapping/conf-mappings.html](http://www.elasticsearch.org/guide/reference/mapping/conf-mappings.html)  
[2] [http://www.elasticsearch.org/guide/reference/mapping/dynamic-mapping.html](http://www.elasticsearch.org/guide/reference/mapping/dynamic-mapping.html)

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [May 14, 2011, 11:54am UTC](https://discuss.elastic.co/t/default-mapping-confusion/4399/2 "2011-05-14T11:54:14Z")

</div>

[2] gets applied to all mappings, ever. [1] is for all indices, but the name of the file is the name of the type.

In any case, the new(er) index templates and dynamic templates are preferred.  
On Friday, May 13, 2011 at 6:57 PM, Greg wrote:

> Hi all
> 
> I have read through the documentation, but am slightly confused by the  
> topic of default mapping.
> 
> Is there a difference between defining config/mappings/\_default/  
> mapping.json as described here[1] and defining config/default-  
> mapping.json as described here[2]?
> 
> Many thanks  
> Greg
> 
> [1] [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/conf-mappings.html)  
> [2] [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/dynamic-mapping.html)

---

<div class="post-metadata">

**Author:** ![Greg](https://avatars.discourse-cdn.com/v4/letter/g/71c47a/32.png) [@Greg](https://discuss.elastic.co/u/Greg)\
**Post date:** [May 15, 2011, 12:57pm UTC](https://discuss.elastic.co/t/default-mapping-confusion/4399/3 "2011-05-15T12:57:35Z")

</div>

Hi Shay

Thanks for clarifying this.

I currently use the following in config/default-mapping.json to  
disable the \_source field and string analyzing across all indexes and  
types:

{  
"_default_" : {  
"\_source" : { "enabled" : false },  
"dynamic\_templates" : [  
{  
"disable\_string\_analyzing" : {  
"match" : "\*",  
"match\_mapping\_type" : "string",  
"mapping" : {  
"type" : "string",  
"index" : "not\_analyzed"  
}  
}  
}  
]  
}  
}

I am trying to convert this to the newer index templates format, with  
little success:

{  
"template" : "_",  
"mappings" : {  
"_" : {  
"\_source" : { "enabled" : false }  
}  
},  
"dynamic\_templates" : [  
{  
"disable\_string\_analyzing" : {  
"match" : "\*",  
"match\_mapping\_type" : "string",  
"mapping" : {  
"type" : "string",  
"index" : "not\_analyzed"  
}  
}  
}  
],  
}

What am I doing wrong?

Many thanks  
Greg

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [May 15, 2011, 2:15pm UTC](https://discuss.elastic.co/t/default-mapping-confusion/4399/4 "2011-05-15T14:15:30Z")

</div>

Its perfectly fine to use the config/default-mapping. If you use the index template, did you use the API to "put" it?  
On Sunday, May 15, 2011 at 3:57 PM, Greg wrote:

> Hi Shay
> 
> Thanks for clarifying this.
> 
> I currently use the following in config/default-mapping.json to  
> disable the \_source field and string analyzing across all indexes and  
> types:
> 
> {  
> "_default_" : {  
> "\_source" : { "enabled" : false },  
> "dynamic\_templates" : [  
> {  
> "disable\_string\_analyzing" : {  
> "match" : "\*",  
> "match\_mapping\_type" : "string",  
> "mapping" : {  
> "type" : "string",  
> "index" : "not\_analyzed"  
> }  
> }  
> }  
> ]  
> }  
> }
> 
> I am trying to convert this to the newer index templates format, with  
> little success:
> 
> {  
> "template" : "_",  
> "mappings" : {  
> "_" : {  
> "\_source" : { "enabled" : false }  
> }  
> },  
> "dynamic\_templates" : [  
> {  
> "disable\_string\_analyzing" : {  
> "match" : "\*",  
> "match\_mapping\_type" : "string",  
> "mapping" : {  
> "type" : "string",  
> "index" : "not\_analyzed"  
> }  
> }  
> }  
> ],  
> }
> 
> What am I doing wrong?
> 
> Many thanks  
> Greg

---

<div class="post-metadata">

**Author:** ![Greg](https://avatars.discourse-cdn.com/v4/letter/g/71c47a/32.png) [@Greg](https://discuss.elastic.co/u/Greg)\
**Post date:** [May 15, 2011, 2:50pm UTC](https://discuss.elastic.co/t/default-mapping-confusion/4399/5 "2011-05-15T14:50:05Z")

</div>

Yes, I PUT it to [http://localhost:9200/\_template/template\_1](http://localhost:9200/_template/template_1).

When I GET the above address, I see:

{  
"template\_1" : {  
"template" : "_",  
"order" : 0,  
"settings" : {  
},  
"mappings" : {  
"_" : {  
"\_source" : {  
"enabled" : false  
},  
"dynamic\_templates" : [ {  
"disable\_string\_analyzing" : {  
"mapping" : {  
"index" : "not\_analyzed",  
"type" : "string"  
},  
"match" : "\*",  
"match\_mapping\_type" : "string"  
}  
} ]  
}  
}  
}  
}

However, when I create a new index, it still has the \_source field and  
the string fields are being tokenized, so the template doesn't appear  
to be getting applied.

If it is perfectly fine to use config/default-mapping.json, I may as  
well continue using this. I was just concerned because you said there  
was a newer method that the old method might become deprecated.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [May 16, 2011, 2:48pm UTC](https://discuss.elastic.co/t/default-mapping-confusion/4399/6 "2011-05-16T14:48:12Z")

</div>

Haven't run it, but the mapping you define are wrong, there is no support for "\*" as the mapping type. There is support for setting the it to _default_.  
On Sunday, May 15, 2011 at 5:50 PM, Greg wrote:

> Yes, I PUT it to [http://localhost:9200/\_template/template\_1](http://localhost:9200/_template/template_1).
> 
> When I GET the above address, I see:
> 
> {  
> "template\_1" : {  
> "template" : "_",  
> "order" : 0,  
> "settings" : {  
> },  
> "mappings" : {  
> "_" : {  
> "\_source" : {  
> "enabled" : false  
> },  
> "dynamic\_templates" : [ {  
> "disable\_string\_analyzing" : {  
> "mapping" : {  
> "index" : "not\_analyzed",  
> "type" : "string"  
> },  
> "match" : "\*",  
> "match\_mapping\_type" : "string"  
> }  
> } ]  
> }  
> }  
> }  
> }
> 
> However, when I create a new index, it still has the \_source field and  
> the string fields are being tokenized, so the template doesn't appear  
> to be getting applied.
> 
> If it is perfectly fine to use config/default-mapping.json, I may as  
> well continue using this. I was just concerned because you said there  
> was a newer method that the old method might become deprecated.

---

<div class="post-metadata">

**Author:** ![Greg](https://avatars.discourse-cdn.com/v4/letter/g/71c47a/32.png) [@Greg](https://discuss.elastic.co/u/Greg)\
**Post date:** [May 16, 2011, 3:26pm UTC](https://discuss.elastic.co/t/default-mapping-confusion/4399/7 "2011-05-16T15:26:55Z")

</div>

Thanks Shay, it is working now using "_default_" instead of "\*".

---

<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 6, 2017, 4:06am UTC](https://discuss.elastic.co/t/default-mapping-confusion/4399/8 "2017-07-06T04:06:06Z")

</div>


