# Can mapping for index be updated for all types in one command

**URL:** https://discuss.elastic.co/t/can-mapping-for-index-be-updated-for-all-types-in-one-command/55665
**Category:** Elasticsearch
**Created:** [July 15, 2016, 10:58pm UTC](https://discuss.elastic.co/t/can-mapping-for-index-be-updated-for-all-types-in-one-command/55665 "2016-07-15T22:58:05Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![zoplex](https://avatars.discourse-cdn.com/v4/letter/z/bc8723/32.png) [@zoplex](https://discuss.elastic.co/u/zoplex)
#### Post date: [July 15, 2016, 10:58pm UTC](https://discuss.elastic.co/t/can-mapping-for-index-be-updated-for-all-types-in-one-command/55665/1 "2016-07-15T22:58:05Z")

</div>

I got another question on related subject - but this seems like a different question - could maps for multiple types in one index be updated with one command? if I put:

curl -X POST 'localhost:9200/testmaps/\_mapping?ignore\_conflicts=true' -d'  
{  
"mappings":  
{  
"properties": {  
"favorite-car" : {  
"type" : "string",  
"fields" : {  
"raw" : {  
"type" : "string",  
"index" : "not\_analyzed"  
}  
}  
}  
}  
}  
}  
}  
I get the error:  
{"error":{"root\_cause":[{"type":"action\_request\_validation\_exception","reason":"Validation Failed: 1: mapping type is missing;"}],"type":"action\_request\_validation\_exception","reason":"Validation Failed: 1: mapping type is missing;"},

If I put:  
curl -X POST 'localhost:9200/testmaps/my\_type\*/\_mapping?ignore\_conflicts=true' -d' etc ...

it looks like the new type gets created with name 'my\_type\*' and any new types created after this do not have the desired mapping.

Is there a way to do this wildcard type map update? There could be a sufficiently large number of types to make separate update impractical.

Thanks in advance.

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [July 17, 2016, 9:59pm UTC](https://discuss.elastic.co/t/can-mapping-for-index-be-updated-for-all-types-in-one-command/55665/2 "2016-07-17T21:59:36Z")

</div>

Mixing types can be dangerous - [https://www.elastic.co/blog/index-vs-type](https://www.elastic.co/blog/index-vs-type)

Also look into templates instead of this, you can apply templates to multiple types/indices.

---

<div class="post-metadata">

### Author: ![zoplex](https://avatars.discourse-cdn.com/v4/letter/z/bc8723/32.png) [@zoplex](https://discuss.elastic.co/u/zoplex)
#### Post date: [July 18, 2016, 12:10am UTC](https://discuss.elastic.co/t/can-mapping-for-index-be-updated-for-all-types-in-one-command/55665/3 "2016-07-18T00:10:36Z")

</div>

Thanks - yes I get that same field name should have same type (string, int) across different document types - that is in place already; But since originally my design had large/variable number of document types - one index pattern, with new index every day, then document types under it for different reasons - but as that number seemed to get very large I was hoping to manage all those document types (that are consistent between them self in terms of data types as you warned above) with one template mapping - but could not find a way to apply one mapping to many different document types with the wildcard as displayed above. So I am looking at the templates - and I tried to apply new template mapping:

curl -X POST 'localhost:9200/testmaps/\_mapping?ignore\_conflicts=true' -d'  
{  
"mappings": ... (above is the full command) and it errored out as not liking that I did not specify document type;  
I tried wildcard for document type but it did not produce desired effect:

curl -X POST 'localhost:9200/testmaps/my\_type\*/\_mapping?ignore\_conflicts=true' -d' etc ...

that still did not have desired effect - so is it true that the document type as in "my\_type\*" cannot have wildcard - which then brings the original question - you have to do it type by type?

Thank you

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [July 18, 2016, 12:18am UTC](https://discuss.elastic.co/t/can-mapping-for-index-be-updated-for-all-types-in-one-command/55665/4 "2016-07-18T00:18:34Z")

</div>

Can you provide a replication with what you are doing and the response?

---

<div class="post-metadata">

### Author: ![zoplex](https://avatars.discourse-cdn.com/v4/letter/z/bc8723/32.png) [@zoplex](https://discuss.elastic.co/u/zoplex)
#### Post date: [July 18, 2016, 3:00pm UTC](https://discuss.elastic.co/t/can-mapping-for-index-be-updated-for-all-types-in-one-command/55665/5 "2016-07-18T15:00:47Z")

</div>

Sure - here is the first command that fails - example where I am trying to set that field as non analyzed:

curl -X POST 'localhost:9200/testmaps/\_mapping?ignore\_conflicts=true' -d'  
{  
"mappings":  
{  
"properties": {  
"favorite-car" : {  
"type" : "string",  
"fields" : {  
"raw" : {  
"type" : "string",  
"index" : "not\_analyzed"  
}  
}  
}  
}  
}  
}  
}  
I get the error:  
{"error":{"root\_cause":[{"type":"action\_request\_validation\_exception","reason":"Validation Failed: 1: mapping type is missing;"}],"type":"action\_request\_validation\_exception","reason":"Validation Failed: 1: mapping type is missing;"},

So error indicates that 'mapping type is missing';

Then I add the type using the wildcard spec - my\_type\*:

curl -X POST 'localhost:9200/testmaps/my\_type\*/\_mapping?ignore\_conflicts=true' -d'  
{  
"properties": {  
"favorite-car" : {  
"type" : "string",  
"fields" : {  
"raw" : {  
"type" : "string",  
"index" : "not\_analyzed"  
}  
}  
}  
}  
}  
}  
}

I get no errors - but it does not work - and it almose seems like it corrupted the es instance I was testing with ...

So if I have large number of types - say mytype1, my\_type2, .. my\_type100, ... how can I manage them all with one template update? The types are being added from time to time and I would much prefer no to have to specify one by one ...

Thank you,

---

<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 5, 2017, 10:34pm UTC](https://discuss.elastic.co/t/can-mapping-for-index-be-updated-for-all-types-in-one-command/55665/6 "2017-07-05T22:34:40Z")

</div>


