# How to set up mapping for common property across all types in index

**URL:** https://discuss.elastic.co/t/how-to-set-up-mapping-for-common-property-across-all-types-in-index/12777
**Category:** Elasticsearch
**Created:** [July 12, 2013, 9:38pm UTC](https://discuss.elastic.co/t/how-to-set-up-mapping-for-common-property-across-all-types-in-index/12777 "2013-07-12T21:38:04Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Paul\_Bellora](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paul_bellora/32/74372_2.png) [@Paul\_Bellora](https://discuss.elastic.co/u/Paul_Bellora)
#### Post date: [July 12, 2013, 9:38pm UTC](https://discuss.elastic.co/t/how-to-set-up-mapping-for-common-property-across-all-types-in-index/12777/1 "2013-07-12T21:38:04Z")

</div>

I have a property that is common to all my document types. I would now like  
to apply a custom mapping to this property across an entire index. I can't  
use default-mapping.json because that's applied to all indexes and I need  
to be able to support different versions of mappings between indexes. Is  
there any other way to specify a mapping for a common property, other than  
explicitly repeating it for each type in my index creation api call? I have  
numerous types and want to avoid that level of verbosity if possible.

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [July 15, 2013, 6:20am UTC](https://discuss.elastic.co/t/how-to-set-up-mapping-for-common-property-across-all-types-in-index/12777/2 "2013-07-15T06:20:39Z")

</div>

Hey

have you seen the index template feature of elasticsearch at

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

maybe that feature can help you.

--Alex

On Fri, Jul 12, 2013 at 11:38 PM, Paul Bellora [bellorap@gmail.com](mailto:bellorap@gmail.com) wrote:

> I have a property that is common to all my document types. I would now  
> like to apply a custom mapping to this property across an entire index. I  
> can't use default-mapping.json because that's applied to all indexes and I  
> need to be able to support different versions of mappings between indexes.  
> Is there any other way to specify a mapping for a common property, other  
> than explicitly repeating it for each type in my index creation api call? I  
> have numerous types and want to avoid that level of verbosity if possible.
> 
> --  
> 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).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Paul\_Bellora](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paul_bellora/32/74372_2.png) [@Paul\_Bellora](https://discuss.elastic.co/u/Paul_Bellora)
#### Post date: [July 15, 2013, 3:43pm UTC](https://discuss.elastic.co/t/how-to-set-up-mapping-for-common-property-across-all-types-in-index/12777/3 "2013-07-15T15:43:44Z")

</div>

Hmm, that's interesting but it still appears to define mappings on a  
per-type basis, at least in that page's examples. Is there a way I can  
leverage index templates to define mappings across all types in the index?

On Mon, Jul 15, 2013 at 2:20 AM, Alexander Reelsen [alr@spinscale.de](mailto:alr@spinscale.de) wrote:

> Hey
> 
> have you seen the index template feature of elasticsearch at  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/admin-indices-templates/)  
> maybe that feature can help you.
> 
> --Alex
> 
> On Fri, Jul 12, 2013 at 11:38 PM, Paul Bellora [bellorap@gmail.com](mailto:bellorap@gmail.com) wrote:
> 
> > I have a property that is common to all my document types. I would now  
> > like to apply a custom mapping to this property across an entire index. I  
> > can't use default-mapping.json because that's applied to all indexes and I  
> > need to be able to support different versions of mappings between indexes.  
> > Is there any other way to specify a mapping for a common property, other  
> > than explicitly repeating it for each type in my index creation api call? I  
> > have numerous types and want to avoid that level of verbosity if possible.
> > 
> > --  
> > 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).
> > 
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> --  
> You received this message because you are subscribed to a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit  
> [https://groups.google.com/d/topic/elasticsearch/nw4LTAmkmPs/unsubscribe](https://groups.google.com/d/topic/elasticsearch/nw4LTAmkmPs/unsubscribe).  
> To unsubscribe from this group and all its topics, send an email to  
> [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![javanna](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javanna/32/4698_2.png) [@javanna](https://discuss.elastic.co/u/javanna)
#### Post date: [July 16, 2013, 11:29am UTC](https://discuss.elastic.co/t/how-to-set-up-mapping-for-common-property-across-all-types-in-index/12777/4 "2013-07-16T11:29:06Z")

</div>

Hi,  
you can use the _default_ type. Have a look  
here: [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/dynamic-mapping/)  
.

The _default_ type is really handy when you have multiple types with a lot  
of similarities. You may want to avoid duplications, thus you define the  
common fields once under the _default_ type, which will be applied  
automatically to all the types that belong to the current index. And of  
course you can combine it with index templates too.

Cheers  
Luca

On Monday, July 15, 2013 5:43:44 PM UTC+2, Paul Bellora wrote:

> Hmm, that's interesting but it still appears to define mappings on a  
> per-type basis, at least in that page's examples. Is there a way I can  
> leverage index templates to define mappings across all types in the index?
> 
> On Mon, Jul 15, 2013 at 2:20 AM, Alexander Reelsen \<[a...@spinscale.de](mailto:a...@spinscale.de)\<javascript:\>
> 
> > wrote:
> 
> > Hey
> > 
> > have you seen the index template feature of elasticsearch at  
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/admin-indices-templates/)  
> > maybe that feature can help you.
> > 
> > --Alex
> > 
> > On Fri, Jul 12, 2013 at 11:38 PM, Paul Bellora \<[bell...@gmail.com](mailto:bell...@gmail.com)\<javascript:\>
> > 
> > > wrote:
> > 
> > > I have a property that is common to all my document types. I would now  
> > > like to apply a custom mapping to this property across an entire index. I  
> > > can't use default-mapping.json because that's applied to all indexes and I  
> > > need to be able to support different versions of mappings between indexes.  
> > > Is there any other way to specify a mapping for a common property, other  
> > > than explicitly repeating it for each type in my index creation api call? I  
> > > have numerous types and want to avoid that level of verbosity if possible.
> > > 
> > > --  
> > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.
> > > 
> > > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> > 
> > --  
> > You received this message because you are subscribed to a topic in the  
> > Google Groups "elasticsearch" group.  
> > To unsubscribe from this topic, visit  
> > [https://groups.google.com/d/topic/elasticsearch/nw4LTAmkmPs/unsubscribe](https://groups.google.com/d/topic/elasticsearch/nw4LTAmkmPs/unsubscribe).  
> > To unsubscribe from this group and all its topics, send an email to  
> > [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Paul\_Bellora](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paul_bellora/32/74372_2.png) [@Paul\_Bellora](https://discuss.elastic.co/u/Paul_Bellora)
#### Post date: [July 17, 2013, 7:30pm UTC](https://discuss.elastic.co/t/how-to-set-up-mapping-for-common-property-across-all-types-in-index/12777/5 "2013-07-17T19:30:46Z")

</div>

Interesting - the concept is exactly what I'm looking for. Unfortunately it  
can't be applied in the way I'd hoped:

curl -X PUT localhost:9200/test -d '{  
"mappings" : {  
"_default_" : {  
"properties" : {  
"foo" : { "index" : "unanalyzed" }  
}  
}  
}  
}'

This yields:

MapperParsingException[mapping [_default_]]; nested:  
MapperParsingException[No type specified for property [foo]];

The documentation says:

The default mapping definition can be overridden in several manners. The  
simplest manner is to simply define a file called default-mapping.json and  
placed it under the config directory (which can be configured to exist in a  
different location). It can also be explicitly set using the  
index.mapper.default\_mapping\_location setting.

So it seems like I would need to make a default mappings file for each  
index and use the default\_mapping\_location property to point to it. This is  
enough of an inconvenience to my reindexing workflow that I think I'll just  
stick to the verbose index settings. Thanks for the suggestions though!

On Tue, Jul 16, 2013 at 7:29 AM, Luca Cavanna [cavannaluca@gmail.com](mailto:cavannaluca@gmail.com) wrote:

> Hi,  
> you can use the _default_ type. Have a look here:  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/dynamic-mapping/) .
> 
> The _default_ type is really handy when you have multiple types with a lot  
> of similarities. You may want to avoid duplications, thus you define the  
> common fields once under the _default_ type, which will be applied  
> automatically to all the types that belong to the current index. And of  
> course you can combine it with index templates too.
> 
> Cheers  
> Luca
> 
> On Monday, July 15, 2013 5:43:44 PM UTC+2, Paul Bellora wrote:
> 
> > Hmm, that's interesting but it still appears to define mappings on a  
> > per-type basis, at least in that page's examples. Is there a way I can  
> > leverage index templates to define mappings across all types in the index?
> > 
> > On Mon, Jul 15, 2013 at 2:20 AM, Alexander Reelsen [a...@spinscale.de](mailto:a...@spinscale.de)wrote:
> > 
> > > Hey
> > > 
> > > have you seen the index template feature of elasticsearch at  
> > > [http://www.elasticsearch](http://www.elasticsearch). **org/guide/reference/api/admin-**  
> > > indices-templates/[http://www.elasticsearch.org/guide/reference/api/admin-indices-templates/](http://www.elasticsearch.org/guide/reference/api/admin-indices-templates/)  
> > > maybe that feature can help you.
> > > 
> > > --Alex
> > > 
> > > On Fri, Jul 12, 2013 at 11:38 PM, Paul Bellora [bell...@gmail.com](mailto:bell...@gmail.com)wrote:
> > > 
> > > > I have a property that is common to all my document types. I would now  
> > > > like to apply a custom mapping to this property across an entire index. I  
> > > > can't use default-mapping.json because that's applied to all indexes and I  
> > > > need to be able to support different versions of mappings between indexes.  
> > > > Is there any other way to specify a mapping for a common property, other  
> > > > than explicitly repeating it for each type in my index creation api call? I  
> > > > have numerous types and want to avoid that level of verbosity if possible.
> > > > 
> > > > --  
> > > > 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 elasticsearc...@\*\*[googlegroups.com](http://googlegroups.com).
> > > > 
> > > > For more options, visit [https://groups.google.com/\*\*groups/opt\_out](https://groups.google.com/**groups/opt_out)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> > > > .
> > > 
> > > --  
> > > You received this message because you are subscribed to a topic in the  
> > > Google Groups "elasticsearch" group.  
> > > To unsubscribe from this topic, visit [https://groups.google.com/d/](https://groups.google.com/d/)\*\*  
> > > topic/elasticsearch/\*\*nw4LTAmkmPs/unsubscribe[https://groups.google.com/d/topic/elasticsearch/nw4LTAmkmPs/unsubscribe](https://groups.google.com/d/topic/elasticsearch/nw4LTAmkmPs/unsubscribe)  
> > > .  
> > > To unsubscribe from this group and all its topics, send an email to  
> > > elasticsearc...@\*\*[googlegroups.com](http://googlegroups.com).
> > > 
> > > For more options, visit [https://groups.google.com/\*\*groups/opt\_out](https://groups.google.com/**groups/opt_out)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> > > .
> > 
> > --  
> > You received this message because you are subscribed to a topic in the  
> > Google Groups "elasticsearch" group.  
> > To unsubscribe from this topic, visit  
> > [https://groups.google.com/d/topic/elasticsearch/nw4LTAmkmPs/unsubscribe](https://groups.google.com/d/topic/elasticsearch/nw4LTAmkmPs/unsubscribe).  
> > To unsubscribe from this group and all its topics, send an email to  
> > [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![javanna](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javanna/32/4698_2.png) [@javanna](https://discuss.elastic.co/u/javanna)
#### Post date: [July 17, 2013, 8:13pm UTC](https://discuss.elastic.co/t/how-to-set-up-mapping-for-common-property-across-all-types-in-index/12777/6 "2013-07-17T20:13:20Z")

</div>

Hey Paul,  
you're on the right track, you only missed the type if your foo field, I guess it should be "type":"string". You're mapping should be ok then, you don't necessarily need to use the file based configuration.

Cheers  
Luca

On 17 Jul 2013, at 21:30, Paul Bellora [bellorap@gmail.com](mailto:bellorap@gmail.com) wrote:

> Interesting - the concept is exactly what I'm looking for. Unfortunately it can't be applied in the way I'd hoped:
> 
> curl -X PUT localhost:9200/test -d '{  
> "mappings" : {  
> "_default_" : {  
> "properties" : {  
> "foo" : { "index" : "unanalyzed" }  
> }  
> }  
> }  
> }'
> 
> This yields:
> 
> MapperParsingException[mapping [_default_]]; nested: MapperParsingException[No type specified for property [foo]];
> 
> The documentation says:
> 
> The default mapping definition can be overridden in several manners. The simplest manner is to simply define a file called default-mapping.json and placed it under the config directory (which can be configured to exist in a different location). It can also be explicitly set using the index.mapper.default\_mapping\_location setting.
> 
> So it seems like I would need to make a default mappings file for each index and use the default\_mapping\_location property to point to it. This is enough of an inconvenience to my reindexing workflow that I think I'll just stick to the verbose index settings. Thanks for the suggestions though!
> 
> On Tue, Jul 16, 2013 at 7:29 AM, Luca Cavanna [cavannaluca@gmail.com](mailto:cavannaluca@gmail.com) wrote:
> 
> > Hi,  
> > you can use the _default_ type. Have a look here: [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/dynamic-mapping/) .
> > 
> > The _default_ type is really handy when you have multiple types with a lot of similarities. You may want to avoid duplications, thus you define the common fields once under the _default_ type, which will be applied automatically to all the types that belong to the current index. And of course you can combine it with index templates too.
> > 
> > Cheers  
> > Luca
> > 
> > On Monday, July 15, 2013 5:43:44 PM UTC+2, Paul Bellora wrote:
> > 
> > > Hmm, that's interesting but it still appears to define mappings on a per-type basis, at least in that page's examples. Is there a way I can leverage index templates to define mappings across all types in the index?
> > > 
> > > On Mon, Jul 15, 2013 at 2:20 AM, Alexander Reelsen [a...@spinscale.de](mailto:a...@spinscale.de) wrote:
> > > 
> > > > Hey
> > > > 
> > > > have you seen the index template feature of elasticsearch at [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/admin-indices-templates/)  
> > > > maybe that feature can help you.
> > > > 
> > > > --Alex
> > > > 
> > > > On Fri, Jul 12, 2013 at 11:38 PM, Paul Bellora [bell...@gmail.com](mailto:bell...@gmail.com) wrote:
> > > > 
> > > > > ## I have a property that is common to all my document types. I would now like to apply a custom mapping to this property across an entire index. I can't use default-mapping.json because that's applied to all indexes and I need to be able to support different versions of mappings between indexes. Is there any other way to specify a mapping for a common property, other than explicitly repeating it for each type in my index creation api call? I have numerous types and want to avoid that level of verbosity if possible.
> > > > > 
> > > > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).
> > > > > 
> > > > > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> > > > 
> > > > --  
> > > > You received this message because you are subscribed to a topic in the Google Groups "elasticsearch" group.  
> > > > To unsubscribe from this topic, visit [https://groups.google.com/d/topic/elasticsearch/nw4LTAmkmPs/unsubscribe](https://groups.google.com/d/topic/elasticsearch/nw4LTAmkmPs/unsubscribe).  
> > > > To unsubscribe from this group and all its topics, send an email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).
> > > > 
> > > > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> > 
> > --  
> > You received this message because you are subscribed to a topic in the Google Groups "elasticsearch" group.  
> > To unsubscribe from this topic, visit [https://groups.google.com/d/topic/elasticsearch/nw4LTAmkmPs/unsubscribe](https://groups.google.com/d/topic/elasticsearch/nw4LTAmkmPs/unsubscribe).  
> > To unsubscribe from this group and all its topics, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> --  
> You received this message because you are subscribed to a topic in the Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit [https://groups.google.com/d/topic/elasticsearch/nw4LTAmkmPs/unsubscribe](https://groups.google.com/d/topic/elasticsearch/nw4LTAmkmPs/unsubscribe).  
> To unsubscribe from this group and all its topics, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Christian\_Th](https://avatars.discourse-cdn.com/v4/letter/c/f14d63/32.png) [@Christian\_Th](https://discuss.elastic.co/u/Christian_Th)
#### Post date: [July 17, 2013, 8:19pm UTC](https://discuss.elastic.co/t/how-to-set-up-mapping-for-common-property-across-all-types-in-index/12777/7 "2013-07-17T20:19:22Z")

</div>

You can take a look into the following thread, if you are interested into a  
dynamic mapping sample:  
[https://groups.google.com/forum/#!msg/elasticsearch/fIOzYaslI\_Q/NMAfS2aDQWoJ](https://groups.google.com/forum/#!msg/elasticsearch/fIOzYaslI_Q/NMAfS2aDQWoJ)

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Paul\_Bellora](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paul_bellora/32/74372_2.png) [@Paul\_Bellora](https://discuss.elastic.co/u/Paul_Bellora)
#### Post date: [July 18, 2013, 3:51pm UTC](https://discuss.elastic.co/t/how-to-set-up-mapping-for-common-property-across-all-types-in-index/12777/8 "2013-07-18T15:51:27Z")

</div>

Oh that was silly of me - I should've read the error more carefully. And I  
even wrote unanalyzed instead of not\_analyzed!. This worked like a charm:

curl -X PUT localhost:9200/test -d '{  
"mappings" : {  
"_default_" : {  
"properties" : {  
"foo" : { "index" : "not\_analyzed", "type" : "string" }  
}  
}  
}  
}'

Thanks for your help!

On Wed, Jul 17, 2013 at 4:13 PM, Luca Cavanna [cavannaluca@gmail.com](mailto:cavannaluca@gmail.com) wrote:

> Hey Paul,  
> you're on the right track, you only missed the type if your foo field, I  
> guess it should be "type":"string". You're mapping should be ok then, you  
> don't necessarily need to use the file based configuration.
> 
> Cheers  
> Luca
> 
> On 17 Jul 2013, at 21:30, Paul Bellora [bellorap@gmail.com](mailto:bellorap@gmail.com) wrote:
> 
> Interesting - the concept is exactly what I'm looking for. Unfortunately  
> it can't be applied in the way I'd hoped:
> 
> curl -X PUT localhost:9200/test -d '{  
> "mappings" : {  
> "_default_" : {  
> "properties" : {  
> "foo" : { "index" : "unanalyzed" }  
> }  
> }  
> }  
> }'
> 
> This yields:
> 
> MapperParsingException[mapping [_default_]]; nested:  
> MapperParsingException[No type specified for property [foo]];
> 
> The documentation says:
> 
> The default mapping definition can be overridden in several manners. The  
> simplest manner is to simply define a file called default-mapping.json and  
> placed it under the config directory (which can be configured to exist in  
> a different location). It can also be explicitly set using the  
> index.mapper.default\_mapping\_location setting.
> 
> So it seems like I would need to make a default mappings file for each  
> index and use the default\_mapping\_location property to point to it. This  
> is enough of an inconvenience to my reindexing workflow that I think I'll  
> just stick to the verbose index settings. Thanks for the suggestions though!
> 
> On Tue, Jul 16, 2013 at 7:29 AM, Luca Cavanna [cavannaluca@gmail.com](mailto:cavannaluca@gmail.com)wrote:
> 
> > Hi,  
> > you can use the _default_ type. Have a look here:  
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/dynamic-mapping/) .
> > 
> > The _default_ type is really handy when you have multiple types with a  
> > lot of similarities. You may want to avoid duplications, thus you define  
> > the common fields once under the _default_ type, which will be applied  
> > automatically to all the types that belong to the current index. And of  
> > course you can combine it with index templates too.
> > 
> > Cheers  
> > Luca
> > 
> > On Monday, July 15, 2013 5:43:44 PM UTC+2, Paul Bellora wrote:
> > 
> > > Hmm, that's interesting but it still appears to define mappings on a  
> > > per-type basis, at least in that page's examples. Is there a way I can  
> > > leverage index templates to define mappings across all types in the index?
> > > 
> > > On Mon, Jul 15, 2013 at 2:20 AM, Alexander Reelsen [a...@spinscale.de](mailto:a...@spinscale.de)wrote:
> > > 
> > > > Hey
> > > > 
> > > > have you seen the index template feature of elasticsearch at  
> > > > [http://www.elasticsearch](http://www.elasticsearch). **org/guide/reference/api/admin-**  
> > > > indices-templates/[http://www.elasticsearch.org/guide/reference/api/admin-indices-templates/](http://www.elasticsearch.org/guide/reference/api/admin-indices-templates/)  
> > > > maybe that feature can help you.
> > > > 
> > > > --Alex
> > > > 
> > > > On Fri, Jul 12, 2013 at 11:38 PM, Paul Bellora [bell...@gmail.com](mailto:bell...@gmail.com)wrote:
> > > > 
> > > > > I have a property that is common to all my document types. I would now  
> > > > > like to apply a custom mapping to this property across an entire index. I  
> > > > > can't use default-mapping.json because that's applied to all indexes and I  
> > > > > need to be able to support different versions of mappings between indexes.  
> > > > > Is there any other way to specify a mapping for a common property, other  
> > > > > than explicitly repeating it for each type in my index creation api call? I  
> > > > > have numerous types and want to avoid that level of verbosity if possible.
> > > > > 
> > > > > --  
> > > > > 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 elasticsearc...@\*\*[googlegroups.com](http://googlegroups.com).
> > > > > 
> > > > > For more options, visit [https://groups.google.com/\*\*groups/opt\_out](https://groups.google.com/**groups/opt_out)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> > > > > .
> > > > 
> > > > --  
> > > > You received this message because you are subscribed to a topic in the  
> > > > Google Groups "elasticsearch" group.  
> > > > To unsubscribe from this topic, visit [https://groups.google.com/d/](https://groups.google.com/d/)\*\*  
> > > > topic/elasticsearch/\*\*nw4LTAmkmPs/unsubscribe[https://groups.google.com/d/topic/elasticsearch/nw4LTAmkmPs/unsubscribe](https://groups.google.com/d/topic/elasticsearch/nw4LTAmkmPs/unsubscribe)  
> > > > .  
> > > > To unsubscribe from this group and all its topics, send an email to  
> > > > elasticsearc...@\*\*[googlegroups.com](http://googlegroups.com).
> > > > 
> > > > For more options, visit [https://groups.google.com/\*\*groups/opt\_out](https://groups.google.com/**groups/opt_out)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> > > > .
> > > 
> > > --  
> > > You received this message because you are subscribed to a topic in the  
> > > Google Groups "elasticsearch" group.  
> > > To unsubscribe from this topic, visit  
> > > [https://groups.google.com/d/topic/elasticsearch/nw4LTAmkmPs/unsubscribe](https://groups.google.com/d/topic/elasticsearch/nw4LTAmkmPs/unsubscribe).  
> > > To unsubscribe from this group and all its topics, send an email to  
> > > [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> --  
> You received this message because you are subscribed to a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit  
> [https://groups.google.com/d/topic/elasticsearch/nw4LTAmkmPs/unsubscribe](https://groups.google.com/d/topic/elasticsearch/nw4LTAmkmPs/unsubscribe).  
> To unsubscribe from this group and all its topics, send an email to  
> [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> --  
> You received this message because you are subscribed to a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit  
> [https://groups.google.com/d/topic/elasticsearch/nw4LTAmkmPs/unsubscribe](https://groups.google.com/d/topic/elasticsearch/nw4LTAmkmPs/unsubscribe).  
> To unsubscribe from this group and all its topics, send an email to  
> [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:25am UTC](https://discuss.elastic.co/t/how-to-set-up-mapping-for-common-property-across-all-types-in-index/12777/9 "2017-07-06T02:25:42Z")

</div>


