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

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)
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 and
didn't notice anything different than what it was when I originally
implemented this.

Thanks,
Bob

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)
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 and didn't notice anything different than what it was when I originally implemented this.

Thanks,
Bob

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.comwrote:

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)
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 and
didn't notice anything different than what it was when I originally
implemented this.

Thanks,
Bob