# Mapping validation error

**URL:** <https://discuss.elastic.co/t/mapping-validation-error/4703>\
**Category:** Elasticsearch\
**Created:** [June 24, 2011, 3:48pm UTC](https://discuss.elastic.co/t/mapping-validation-error/4703 "2011-06-24T15:48:23Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Curtis\_Caravone](https://avatars.discourse-cdn.com/v4/letter/c/e47c2d/32.png) [@Curtis\_Caravone](https://discuss.elastic.co/u/Curtis_Caravone)\
**Post date:** [June 24, 2011, 3:48pm UTC](https://discuss.elastic.co/t/mapping-validation-error/4703/1 "2011-06-24T15:48:23Z")

</div>

Hi all,

I'm running 0.16.2, both client and server. When I start up my app,  
connecting to a stand-alone elasticsearch instance, I get an index mapping  
validation error:

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)  
at  
org.elasticsearch.client.action.admin.indices.support.BaseIndicesRequestBuilder.execute(BaseIndicesRequestBuilder.java:52)  
at  
org.elasticsearch.client.action.admin.indices.support.BaseIndicesRequestBuilder.execute(BaseIndicesRequestBuilder.java:47)

I think the problem is a dynamic template where I don't specify a field  
type.

Now the strange part: None of my unit tests around this code caught the  
error, even though I run the exact same put mapping code in the test.

The only difference I can find between the two is that production uses a  
regular client node:

```
    node = nodeBuilder().
            clusterName(clusterName).
            client(true).
            node();
    client = node.client();

```

while test uses a local node:

```
    node = NodeBuilder.nodeBuilder()
                      .local(true)
                      .settings(settingsBuilder()
                              .put("gateway", "none")
                              .put("http.enabled", false)
                              .put("path.data",

```

"target/var/elasticsearch/data")  
)  
.node();  
client = node.client();

Is it possible that the local node bypasses mapping validation somehow? Is  
there a way I can catch this in a test without starting up an actual  
discoverable elasticsearch instance?

Curtis

---

<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 24, 2011, 3:59pm UTC](https://discuss.elastic.co/t/mapping-validation-error/4703/2 "2011-06-24T15:59:33Z")

</div>

In 0.16.2 you have to specify the mapping type when using the putMapping API. There were corner cases when not providing it, so now its required. Just call setType on it.

On Friday, June 24, 2011 at 6:48 PM, Curtis Caravone wrote:

> Hi all,
> 
> I'm running 0.16.2, both client and server. When I start up my app, connecting to a stand-alone elasticsearch instance, I get an index mapping validation error:
> 
> 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)  
> at org.elasticsearch.client.action.admin.indices.support.BaseIndicesRequestBuilder.execute(BaseIndicesRequestBuilder.java:52)  
> at org.elasticsearch.client.action.admin.indices.support.BaseIndicesRequestBuilder.execute(BaseIndicesRequestBuilder.java:47)
> 
> I think the problem is a dynamic template where I don't specify a field type.
> 
> Now the strange part: None of my unit tests around this code caught the error, even though I run the exact same put mapping code in the test.
> 
> The only difference I can find between the two is that production uses a regular client node:
> 
> node = nodeBuilder().  
> clusterName(clusterName).  
> client(true).  
> node();  
> client = node.client();
> 
> while test uses a local node:
> 
> node = NodeBuilder.nodeBuilder()  
> .local(true)  
> .settings(settingsBuilder()  
> .put("gateway", "none")  
> .put("http.enabled", false)  
> .put("path.data", "target/var/elasticsearch/data")  
> )  
> .node();
> 
> client = node.client();
> 
> Is it possible that the local node bypasses mapping validation somehow? Is there a way I can catch this in a test without starting up an actual discoverable elasticsearch instance?
> 
> Curtis

---

<div class="post-metadata">

**Author:** ![Curtis\_Caravone](https://avatars.discourse-cdn.com/v4/letter/c/e47c2d/32.png) [@Curtis\_Caravone](https://discuss.elastic.co/u/Curtis_Caravone)\
**Post date:** [June 24, 2011, 6:14pm UTC](https://discuss.elastic.co/t/mapping-validation-error/4703/3 "2011-06-24T18:14:04Z")

</div>

Sorry about that -- user error. My unit test was pulling in the wrong  
elasticsearch version. Fixed the version and now the unit tests catch my  
mapping error.

thanks!

Curtis

On Fri, Jun 24, 2011 at 8:59 AM, Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)wrote:

> In 0.16.2 you have to specify the mapping type when using the putMapping  
> API. There were corner cases when not providing it, so now its required.  
> Just call setType on it.
> 
> On Friday, June 24, 2011 at 6:48 PM, Curtis Caravone wrote:
> 
> Hi all,
> 
> I'm running 0.16.2, both client and server. When I start up my app,  
> connecting to a stand-alone elasticsearch instance, I get an index mapping  
> validation error:
> 
> 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)  
> at  
> org.elasticsearch.client.action.admin.indices.support.BaseIndicesRequestBuilder.execute(BaseIndicesRequestBuilder.java:52)  
> at  
> org.elasticsearch.client.action.admin.indices.support.BaseIndicesRequestBuilder.execute(BaseIndicesRequestBuilder.java:47)
> 
> I think the problem is a dynamic template where I don't specify a field  
> type.
> 
> Now the strange part: None of my unit tests around this code caught the  
> error, even though I run the exact same put mapping code in the test.
> 
> The only difference I can find between the two is that production uses a  
> regular client node:
> 
> ```
> node = nodeBuilder().
> clusterName(clusterName).
> client(true).
> node();
> client = node.client();
> 
> ```
> 
> while test uses a local node:
> 
> ```
> node = NodeBuilder.nodeBuilder()
> .local(true)
> .settings(settingsBuilder()
> .put("gateway", "none")
> .put("http.enabled", false)
> .put("path.data",
> 
> ```
> 
> "target/var/elasticsearch/data")  
> )  
> .node();  
> client = node.client();
> 
> Is it possible that the local node bypasses mapping validation somehow? Is  
> there a way I can catch this in a test without starting up an actual  
> discoverable elasticsearch instance?
> 
> Curtis

---

<div class="post-metadata">

**Author:** ![Curtis\_Caravone](https://avatars.discourse-cdn.com/v4/letter/c/e47c2d/32.png) [@Curtis\_Caravone](https://discuss.elastic.co/u/Curtis_Caravone)\
**Post date:** [June 24, 2011, 7:33pm UTC](https://discuss.elastic.co/t/mapping-validation-error/4703/4 "2011-06-24T19:33:43Z")

</div>

Ok, got a valid mapping, but now I'm having trouble getting it to work as  
expected.

My goal is to create a mapping that indexes only the fields I need to search  
on, rather than all fields in the document.

I attempted to do this by creating a dynamic template that sets all fields  
to "index": "no", followed by specific mappings for the few fields I want to  
index.

Everything works as expected, except that all fields are getting indexed (I  
can tell by browsing the Lucene index using luke).

When I comment out the section with the specific field mappings, I do get a  
result without any fields indexed (except maybe the \_uid field).

Is there a better way to attempt to do this?

Curtis

On Fri, Jun 24, 2011 at 11:14 AM, Curtis Caravone [caravone@gmail.com](mailto:caravone@gmail.com)wrote:

> Sorry about that -- user error. My unit test was pulling in the wrong  
> elasticsearch version. Fixed the version and now the unit tests catch my  
> mapping error.
> 
> thanks!
> 
> Curtis
> 
> On Fri, Jun 24, 2011 at 8:59 AM, Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)wrote:
> 
> > In 0.16.2 you have to specify the mapping type when using the putMapping  
> > API. There were corner cases when not providing it, so now its required.  
> > Just call setType on it.
> > 
> > On Friday, June 24, 2011 at 6:48 PM, Curtis Caravone wrote:
> > 
> > Hi all,
> > 
> > I'm running 0.16.2, both client and server. When I start up my app,  
> > connecting to a stand-alone elasticsearch instance, I get an index mapping  
> > validation error:
> > 
> > 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)  
> > at  
> > org.elasticsearch.client.action.admin.indices.support.BaseIndicesRequestBuilder.execute(BaseIndicesRequestBuilder.java:52)  
> > at  
> > org.elasticsearch.client.action.admin.indices.support.BaseIndicesRequestBuilder.execute(BaseIndicesRequestBuilder.java:47)
> > 
> > I think the problem is a dynamic template where I don't specify a field  
> > type.
> > 
> > Now the strange part: None of my unit tests around this code caught the  
> > error, even though I run the exact same put mapping code in the test.
> > 
> > The only difference I can find between the two is that production uses a  
> > regular client node:
> > 
> > ```
> > node = nodeBuilder().
> > clusterName(clusterName).
> > client(true).
> > node();
> > client = node.client();
> > 
> > ```
> > 
> > while test uses a local node:
> > 
> > ```
> > node = NodeBuilder.nodeBuilder()
> > .local(true)
> > .settings(settingsBuilder()
> > .put("gateway", "none")
> > .put("http.enabled", false)
> > .put("path.data",
> > 
> > ```
> > 
> > "target/var/elasticsearch/data")  
> > )  
> > .node();  
> > client = node.client();
> > 
> > Is it possible that the local node bypasses mapping validation somehow?  
> > Is there a way I can catch this in a test without starting up an actual  
> > discoverable elasticsearch instance?
> > 
> > Curtis

---

<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:02am UTC](https://discuss.elastic.co/t/mapping-validation-error/4703/5 "2017-07-06T04:02:38Z")

</div>


