# 0.16.1 to 0.16.2 upgrade causes "Validation Failed: 1: mapping type is missing" when adding dynamic template

**URL:** <https://discuss.elastic.co/t/0-16-1-to-0-16-2-upgrade-causes-validation-failed-1-mapping-type-is-missing-when-adding-dynamic-template/4624>\
**Category:** Elasticsearch\
**Created:** [June 14, 2011, 11:29pm UTC](https://discuss.elastic.co/t/0-16-1-to-0-16-2-upgrade-causes-validation-failed-1-mapping-type-is-missing-when-adding-dynamic-template/4624 "2011-06-14T23:29:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jacorob](https://avatars.discourse-cdn.com/v4/letter/j/dec6dc/32.png) [@jacorob](https://discuss.elastic.co/u/jacorob)\
**Post date:** [June 14, 2011, 11:29pm UTC](https://discuss.elastic.co/t/0-16-1-to-0-16-2-upgrade-causes-validation-failed-1-mapping-type-is-missing-when-adding-dynamic-template/4624/1 "2011-06-14T23:29:46Z")

</div>

I'm adding a dynamic template so that, by default, string types are not  
analyzed in my index. The code worked fine in 0.16.1, but when I upgraded to  
0.16.2 I get an ActionRequestValidationException:  
Caused by: org.elasticsearch.action.ActionRequestValidationException:  
Validation Failed: 1: mapping type is missing  
at org.elasticsearch.action.Actions.addValidationError(Actions.java:32)  
at  
org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest.validate(PutMappingRequest.java:80)  
at org.elasticsearch.action.support.BaseAction.execute(BaseAction.java:55)  
at  
org.elasticsearch.client.node.NodeIndicesAdminClient.putMapping(NodeIndicesAdminClient.java:223)  
at  
org.elasticsearch.client.action.admin.indices.mapping.put.PutMappingRequestBuilder.doExecute(PutMappingRequestBuilder.java:116)

The java code is as follows (in gist - [https://gist.github.com/1026176](https://gist.github.com/1026176))  
PutMappingResponse pmResponse =  
getNodeClient().admin().indices().preparePutMapping(indexName)  
.setSource("{\n" +  
" "_default_" : {\n" +  
" "dynamic\_templates" : [\n" +  
" {\n" +  
" "index\_nonanalyzed" : {\n" +  
" "match" : "\*",\n" +  
" "match\_mapping\_type" :  
"string",\n" +  
" "mapping" : {\n" +  
" "index" :  
"not\_analyzed"\n" +  
" }\n" +  
" }\n" +  
" }\n" +  
" ]\n" +  
" }\n" +  
"}"  
)  
.execute().actionGet();

Any input into what I need to change for 0.16.2 would be appreciated. I  
didn't see anything obvious when looking through the changelogs, but I  
obviously missed something. I looked at  
[http://www.elasticsearch.org/guide/reference/mapping/root-object-type.html](http://www.elasticsearch.org/guide/reference/mapping/root-object-type.html) and  
didn't notice anything different than what it was when I originally  
implemented this.

Thanks,  
Bob

---

<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:** [June 14, 2011, 11:31pm UTC](https://discuss.elastic.co/t/0-16-1-to-0-16-2-upgrade-causes-validation-failed-1-mapping-type-is-missing-when-adding-dynamic-template/4624/2 "2011-06-14T23:31:13Z")

</div>

Just add setType to the put mapping request with "_default_" as value. There were some corner cases when the mapping was not provided, so now its required.

On Wednesday, June 15, 2011 at 2:29 AM, Bob Jacoby wrote:

> I'm adding a dynamic template so that, by default, string types are not analyzed in my index. The code worked fine in 0.16.1, but when I upgraded to 0.16.2 I get an ActionRequestValidationException:  
> Caused by: org.elasticsearch.action.ActionRequestValidationException: Validation Failed: 1: mapping type is missing  
> at org.elasticsearch.action.Actions.addValidationError(Actions.java:32)  
> at org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest.validate(PutMappingRequest.java:80)  
> at org.elasticsearch.action.support.BaseAction.execute(BaseAction.java:55)  
> at org.elasticsearch.client.node.NodeIndicesAdminClient.putMapping(NodeIndicesAdminClient.java:223)  
> at org.elasticsearch.client.action.admin.indices.mapping.put.PutMappingRequestBuilder.doExecute(PutMappingRequestBuilder.java:116)
> 
> The java code is as follows (in gist - [Mapping failure · GitHub](https://gist.github.com/1026176))  
> PutMappingResponse pmResponse = getNodeClient().admin().indices().preparePutMapping(indexName)  
> .setSource("{\n" +  
> " "_default_" : {\n" +  
> " "dynamic\_templates" : [\n" +  
> " {\n" +  
> " "index\_nonanalyzed" : {\n" +  
> " "match" : "\*",\n" +  
> " "match\_mapping\_type" : "string",\n" +  
> " "mapping" : {\n" +  
> " "index" : "not\_analyzed"\n" +  
> " }\n" +  
> " }\n" +  
> " }\n" +  
> " ]\n" +  
> " }\n" +  
> "}"  
> )  
> .execute().actionGet();
> 
> Any input into what I need to change for 0.16.2 would be appreciated. I didn't see anything obvious when looking through the changelogs, but I obviously missed something. I looked at [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/root-object-type.html) and didn't notice anything different than what it was when I originally implemented this.
> 
> Thanks,  
> Bob

---

<div class="post-metadata">

**Author:** ![jacorob](https://avatars.discourse-cdn.com/v4/letter/j/dec6dc/32.png) [@jacorob](https://discuss.elastic.co/u/jacorob)\
**Post date:** [June 14, 2011, 11:34pm UTC](https://discuss.elastic.co/t/0-16-1-to-0-16-2-upgrade-causes-validation-failed-1-mapping-type-is-missing-when-adding-dynamic-template/4624/3 "2011-06-14T23:34:25Z")

</div>

Wow! Now that was a fast response. I was looking in the completely wrong  
place since I just assumed my source was wrong (which it is 99% of the  
time). Thanks for saving me even more time down that rabbit hole!

Bob

On Tue, Jun 14, 2011 at 6:31 PM, Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)wrote:

> Just add setType to the put mapping request with "_default_" as value.  
> There were some corner cases when the mapping was not provided, so now its  
> required.
> 
> On Wednesday, June 15, 2011 at 2:29 AM, Bob Jacoby wrote:
> 
> I'm adding a dynamic template so that, by default, string types are not  
> analyzed in my index. The code worked fine in 0.16.1, but when I upgraded to  
> 0.16.2 I get an ActionRequestValidationException:  
> Caused by: org.elasticsearch.action.ActionRequestValidationException:  
> Validation Failed: 1: mapping type is missing  
> at org.elasticsearch.action.Actions.addValidationError(Actions.java:32)  
> at  
> org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest.validate(PutMappingRequest.java:80)  
> at  
> org.elasticsearch.action.support.BaseAction.execute(BaseAction.java:55)  
> at  
> org.elasticsearch.client.node.NodeIndicesAdminClient.putMapping(NodeIndicesAdminClient.java:223)  
> at  
> org.elasticsearch.client.action.admin.indices.mapping.put.PutMappingRequestBuilder.doExecute(PutMappingRequestBuilder.java:116)
> 
> The java code is as follows (in gist - [Mapping failure · GitHub](https://gist.github.com/1026176))  
> PutMappingResponse pmResponse =  
> getNodeClient().admin().indices().preparePutMapping(indexName)  
> .setSource("{\n" +  
> " "_default_" : {\n" +  
> " "dynamic\_templates" : [\n" +  
> " {\n" +  
> " "index\_nonanalyzed" : {\n" +  
> " "match" : "\*",\n" +  
> " "match\_mapping\_type" :  
> "string",\n" +  
> " "mapping" : {\n" +  
> " "index" :  
> "not\_analyzed"\n" +  
> " }\n" +  
> " }\n" +  
> " }\n" +  
> " ]\n" +  
> " }\n" +  
> "}"  
> )  
> .execute().actionGet();
> 
> Any input into what I need to change for 0.16.2 would be appreciated. I  
> didn't see anything obvious when looking through the changelogs, but I  
> obviously missed something. I looked at  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/root-object-type.html) and  
> didn't notice anything different than what it was when I originally  
> implemented this.
> 
> Thanks,  
> Bob

---

<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:03am UTC](https://discuss.elastic.co/t/0-16-1-to-0-16-2-upgrade-causes-validation-failed-1-mapping-type-is-missing-when-adding-dynamic-template/4624/4 "2017-07-06T04:03:34Z")

</div>


