# Where are mappings for indices stored?

**URL:** <https://discuss.elastic.co/t/where-are-mappings-for-indices-stored/3755>\
**Category:** Elasticsearch\
**Created:** [January 8, 2011, 3:07am UTC](https://discuss.elastic.co/t/where-are-mappings-for-indices-stored/3755 "2011-01-08T03:07:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![didier\_deshommes](https://avatars.discourse-cdn.com/v4/letter/d/b9bd4f/32.png) [@didier\_deshommes](https://discuss.elastic.co/u/didier_deshommes)\
**Post date:** [January 8, 2011, 3:07am UTC](https://discuss.elastic.co/t/where-are-mappings-for-indices-stored/3755/1 "2011-01-08T03:07:24Z")

</div>

Hi,  
I would like to be able to store mappings for my indices in a json/yml  
file, so that whenever I add a document to the index, I don't have to  
specify a mapping via the put\_mapping api call. The documentation  
seems to have multiple places for configuring something like that:

- [http://www.elasticsearch.com/docs/elasticsearch/mapping/dynamic\_mapping/](http://www.elasticsearch.com/docs/elasticsearch/mapping/dynamic_mapping/)  
:" The simplest manner is to simply define a file called  
default-mapping.json and placed it under the config directory"

- [http://www.elasticsearch.com/docs/elasticsearch/mapping/builtin\_mappings/](http://www.elasticsearch.com/docs/elasticsearch/mapping/builtin_mappings/)  
: "Mappings can be defined within files called [mapping\_name].json and  
be placed either under config/mappings/\_default location, or under  
config/mappings/[index\_name] (for mappings that should be associated  
only with a specific index)." There seems to be conflicting  
information about how to store the name of the mapping. Is it  
config/mapping/[index\_name] or config/mapping/[index\_name].json ?

The thing is that none of these options seem to work. Does anyone  
have a working mapping file that works? I'm using ES 0.14.1.

didier

---

<div class="post-metadata">

**Author:** ![Lukas\_Vlcek1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukas_vlcek1/32/819_2.png) [@Lukas\_Vlcek1](https://discuss.elastic.co/u/Lukas_Vlcek1)\
**Post date:** [January 10, 2011, 10:07am UTC](https://discuss.elastic.co/t/where-are-mappings-for-indices-stored/3755/2 "2011-01-10T10:07:31Z")

</div>

Hi,

I haven't been using default-mapping.json file so far but see my comments on  
the other options below:

On Sat, Jan 8, 2011 at 4:07 AM, didier deshommes [dfdeshom@gmail.com](mailto:dfdeshom@gmail.com) wrote:

> Hi,  
> I would like to be able to store mappings for my indices in a json/yml  
> file, so that whenever I add a document to the index, I don't have to  
> specify a mapping via the put\_mapping api call. The documentation  
> seems to have multiple places for configuring something like that:
> 
> - [http://www.elasticsearch.com/docs/elasticsearch/mapping/dynamic\_mapping/](http://www.elasticsearch.com/docs/elasticsearch/mapping/dynamic_mapping/)  
> :" The simplest manner is to simply define a file called  
> default-mapping.json and placed it under the config directory"

> - 
> 
> [http://www.elasticsearch.com/docs/elasticsearch/mapping/builtin\_mappings/](http://www.elasticsearch.com/docs/elasticsearch/mapping/builtin_mappings/)  
> : "Mappings can be defined within files called [mapping\_name].json and  
> be placed either under config/mappings/\_default location, or under  
> config/mappings/[index\_name] (for mappings that should be associated  
> only with a specific index)." There seems to be conflicting  
> information about how to store the name of the mapping. Is it  
> config/mapping/[index\_name] or config/mapping/[index\_name].json ?

take the following file foo,json:  
{  
"foo" : {  
"properties" : {  
"howdy" : { "type" : "string", "index" : "not\_analyzed" }  
}  
}  
}

Placing this file into  
config/mappings/\_default/foo.json  
means that whenever a new index is created it will be created with mappings  
for foo type.

Placing it to  
config/mappings/bar/foo.json  
means that whenever an index called bar is created it will be created with  
mappings for foo type.

> The thing is that none of these options seem to work. Does anyone  
> have a working mapping file that works? I'm using ES 0.14.1.

You can also take a look at index templates:  
[http://www.elasticsearch.com/docs/elasticsearch/rest\_api/admin/indices/templates/](http://www.elasticsearch.com/docs/elasticsearch/rest_api/admin/indices/templates/)  
With index templates you PUT the mapping into cluster once and it becomes  
part of the cluster metadata and is available to any newly started node that  
joins the cluster.

> didier

Regards,  
Lukas

---

<div class="post-metadata">

**Author:** ![didier\_deshommes](https://avatars.discourse-cdn.com/v4/letter/d/b9bd4f/32.png) [@didier\_deshommes](https://discuss.elastic.co/u/didier_deshommes)\
**Post date:** [January 11, 2011, 6:53pm UTC](https://discuss.elastic.co/t/where-are-mappings-for-indices-stored/3755/3 "2011-01-11T18:53:21Z")

</div>

On Mon, Jan 10, 2011 at 4:07 AM, Lukáš Vlček [lukas.vlcek@gmail.com](mailto:lukas.vlcek@gmail.com) wrote:

> take the following file foo,json:  
> {  
> "foo" : {  
> "properties" : {  
> "howdy" : { "type" : "string", "index" : "not\_analyzed" }  
> }  
> }  
> }  
> Placing this file into  
> config/mappings/\_default/foo.json  
> means that whenever a new index is created it will be created with mappings  
> for foo type.  
> Placing it to  
> config/mappings/bar/foo.json  
> means that whenever an index called bar is created it will be created with  
> mappings for foo type.

Hi,  
Thanks for the clarifications, I didn't realize that  
config/mappings/\_default/ was actually a directory. Everything worked  
out beautifully.

> > The thing is that none of these options seem to work. Does anyone  
> > have a working mapping file that works? I'm using ES 0.14.1.
> 
> You can also take a look at index  
> templates: [http://www.elasticsearch.com/docs/elasticsearch/rest\_api/admin/indices/templates/](http://www.elasticsearch.com/docs/elasticsearch/rest_api/admin/indices/templates/)  
> With index templates you PUT the mapping into cluster once and it becomes  
> part of the cluster metadata and is available to any newly started node that  
> joins the cluster.

Thanks! good to know.

didier

---

<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:14am UTC](https://discuss.elastic.co/t/where-are-mappings-for-indices-stored/3755/4 "2017-07-06T04:14:03Z")

</div>


