# Setting up default mapping Elasticsearch

**URL:** <https://discuss.elastic.co/t/setting-up-default-mapping-elasticsearch/20043>\
**Category:** Elasticsearch\
**Created:** [October 2, 2014, 9:08am UTC](https://discuss.elastic.co/t/setting-up-default-mapping-elasticsearch/20043 "2014-10-02T09:08:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Adrian\_Luna](https://avatars.discourse-cdn.com/v4/letter/a/258eb7/32.png) [@Adrian\_Luna](https://discuss.elastic.co/u/Adrian_Luna)\
**Post date:** [October 2, 2014, 9:08am UTC](https://discuss.elastic.co/t/setting-up-default-mapping-elasticsearch/20043/1 "2014-10-02T09:08:53Z")

</div>

From the documentation you can set up default mapping definition for every  
index just putting the .json file inside  
$ELASTICSEARCH\_HOME/config/mappings/\_default

However, after doing this, I just get the error:

MapperParsingException[mapping [default\_mapping]]; nested:  
MapperParsingException[Root type mapping not empty after parsing!

My mapping file looks like:

```
 {
  "event" : {
    "dynamic_templates" : [
      {
        "template_1" : {
          "match" : "*",
          "mapping" : {
            "type" : "string",
            "index": "not_analyzed"
          }
        }
      }
    ]
  }
}

```

The problem is that I need to setup several things for each index I create,  
but I don't want to care about updating the map per index, since I would  
need to ask if the index exists before doing this. That means, during my  
workflow I just want to index documents, do not want to care about settings  
stuff.

Thanks in advance!

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/749e68d9-24c7-4f5f-aa69-4c60b4c2c766%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/749e68d9-24c7-4f5f-aa69-4c60b4c2c766%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Adrian\_Luna](https://avatars.discourse-cdn.com/v4/letter/a/258eb7/32.png) [@Adrian\_Luna](https://discuss.elastic.co/u/Adrian_Luna)\
**Post date:** [October 2, 2014, 9:19am UTC](https://discuss.elastic.co/t/setting-up-default-mapping-elasticsearch/20043/2 "2014-10-02T09:19:39Z")

</div>

Ok , I think I solved the issue using index templates. However, I still  
feel like there's something missing here.. so I would appreciate any  
further information...

Cheers

El jueves, 2 de octubre de 2014 11:08:53 UTC+2, Adrian Luna escribió:

> From the documentation you can set up default mapping definition for every  
> index just putting the .json file inside  
> $ELASTICSEARCH\_HOME/config/mappings/\_default
> 
> However, after doing this, I just get the error:
> 
> MapperParsingException[mapping [default\_mapping]]; nested:  
> MapperParsingException[Root type mapping not empty after parsing!
> 
> My mapping file looks like:
> 
> ```
> {
> "event" : {
> "dynamic_templates" : [
> {
> "template_1" : {
> "match" : "*",
> "mapping" : {
> "type" : "string",
> "index": "not_analyzed"
> }
> }
> }
> ]
> }
> }
> 
> ```
> 
> The problem is that I need to setup several things for each index I  
> create, but I don't want to care about updating the map per index, since I  
> would need to ask if the index exists before doing this. That means, during  
> my workflow I just want to index documents, do not want to care about  
> settings stuff.
> 
> Thanks in advance!

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/99f3e281-a3cc-47b8-aaae-5b5912a4ccd8%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/99f3e281-a3cc-47b8-aaae-5b5912a4ccd8%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Tanguy\_Leroux](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tanguy_leroux/32/121066_2.png) [@Tanguy\_Leroux](https://discuss.elastic.co/u/Tanguy_Leroux)\
**Post date:** [October 2, 2014, 9:42am UTC](https://discuss.elastic.co/t/setting-up-default-mapping-elasticsearch/20043/3 "2014-10-02T09:42:49Z")

</div>

Using index templates is definitely the way to go 🙂

Which version of ES are you using?

-- Tanguy

Le jeudi 2 octobre 2014 11:19:39 UTC+2, Adrian Luna a écrit :

> Ok , I think I solved the issue using index templates. However, I still  
> feel like there's something missing here.. so I would appreciate any  
> further information...
> 
> Cheers
> 
> El jueves, 2 de octubre de 2014 11:08:53 UTC+2, Adrian Luna escribió:
> 
> > From the documentation you can set up default mapping definition for  
> > every index just putting the .json file inside  
> > $ELASTICSEARCH\_HOME/config/mappings/\_default
> > 
> > However, after doing this, I just get the error:
> > 
> > MapperParsingException[mapping [default\_mapping]]; nested:  
> > MapperParsingException[Root type mapping not empty after parsing!
> > 
> > My mapping file looks like:
> > 
> > ```
> > {
> > "event" : {
> > "dynamic_templates" : [
> > {
> > "template_1" : {
> > "match" : "*",
> > "mapping" : {
> > "type" : "string",
> > "index": "not_analyzed"
> > }
> > }
> > }
> > ]
> > }
> > }
> > 
> > ```
> > 
> > The problem is that I need to setup several things for each index I  
> > create, but I don't want to care about updating the map per index, since I  
> > would need to ask if the index exists before doing this. That means, during  
> > my workflow I just want to index documents, do not want to care about  
> > settings stuff.
> > 
> > Thanks in advance!

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/9e01d620-245a-4395-8d6c-a624792e1db0%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/9e01d620-245a-4395-8d6c-a624792e1db0%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Adrian\_Luna](https://avatars.discourse-cdn.com/v4/letter/a/258eb7/32.png) [@Adrian\_Luna](https://discuss.elastic.co/u/Adrian_Luna)\
**Post date:** [October 2, 2014, 9:48am UTC](https://discuss.elastic.co/t/setting-up-default-mapping-elasticsearch/20043/4 "2014-10-02T09:48:06Z")

</div>

i've tried it with 1.1.X, 1.2,X and 1.3.X.  
1.1.X won't give an error because it doesn't make use of the default  
mapping.  
In the other versions, the default mapping is not working at all.

Thanks, I'll use the index templates since it works perfectly.

El jueves, 2 de octubre de 2014 11:42:49 UTC+2, Tanguy Leroux escribió:

> Using index templates is definitely the way to go 🙂
> 
> Which version of ES are you using?
> 
> -- Tanguy
> 
> Le jeudi 2 octobre 2014 11:19:39 UTC+2, Adrian Luna a écrit :
> 
> > Ok , I think I solved the issue using index templates. However, I still  
> > feel like there's something missing here.. so I would appreciate any  
> > further information...
> > 
> > Cheers
> > 
> > El jueves, 2 de octubre de 2014 11:08:53 UTC+2, Adrian Luna escribió:
> > 
> > > From the documentation you can set up default mapping definition for  
> > > every index just putting the .json file inside  
> > > $ELASTICSEARCH\_HOME/config/mappings/\_default
> > > 
> > > However, after doing this, I just get the error:
> > > 
> > > MapperParsingException[mapping [default\_mapping]]; nested:  
> > > MapperParsingException[Root type mapping not empty after parsing!
> > > 
> > > My mapping file looks like:
> > > 
> > > ```
> > > {
> > > "event" : {
> > > "dynamic_templates" : [
> > > {
> > > "template_1" : {
> > > "match" : "*",
> > > "mapping" : {
> > > "type" : "string",
> > > "index": "not_analyzed"
> > > }
> > > }
> > > }
> > > ]
> > > }
> > > }
> > > 
> > > ```
> > > 
> > > The problem is that I need to setup several things for each index I  
> > > create, but I don't want to care about updating the map per index, since I  
> > > would need to ask if the index exists before doing this. That means, during  
> > > my workflow I just want to index documents, do not want to care about  
> > > settings stuff.
> > > 
> > > Thanks in advance!

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/7daf698a-2f2c-44c2-9b14-9fc2b4f26338%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/7daf698a-2f2c-44c2-9b14-9fc2b4f26338%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 12:58am UTC](https://discuss.elastic.co/t/setting-up-default-mapping-elasticsearch/20043/5 "2017-07-06T00:58:43Z")

</div>


