# Problem with dynamic-mapping.json

**URL:** <https://discuss.elastic.co/t/problem-with-dynamic-mapping-json/3170>\
**Category:** Elasticsearch\
**Created:** [July 29, 2010, 11:25am UTC](https://discuss.elastic.co/t/problem-with-dynamic-mapping-json/3170 "2010-07-29T11:25:40Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![talsalmona](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/talsalmona/32/3316_2.png) [@talsalmona](https://discuss.elastic.co/u/talsalmona)\
**Post date:** [July 29, 2010, 11:25am UTC](https://discuss.elastic.co/t/problem-with-dynamic-mapping-json/3170/1 "2010-07-29T11:25:40Z")

</div>

Hi,

We are working on a system that requires each tenant to have their own  
index. Each index may have multiple object types (in the example  
below: aaa and xxx). We need to control the field names so we wanted  
to use the conf/dynamic-mapping.json file to define the field names in  
advance.  
We prefer to do this when the system is loaded instead of having to  
redefine it for each tenant when it is created.

The dynamic-mapping.json includes two objects, like so:

{  
"xxx" : {  
"type" : "object",  
"path" : "just\_name",  
"properties" : {  
"yyy" : {  
"type" : "object",  
"path" : "just\_name",  
"properties" : {  
"field3" : { "index\_name" : "f3", type: "string" },  
"field1" : { "index\_name" : "f1", type: "string" }  
}  
}  
}  
},

```
"aaa" : {
  "type" : "object",
  "path" : "just_name",
  "properties" : {
    "bbb" : {
      "type" : "object",
      "path" : "just_name",
      "properties" : {
        "field2" : { "index_name" : "f2", type: "string" },
        "field1" : { "index_name" : "f1", type: "string" }
      }
    }
  }
}

```

}

When doing this, we get an exeption when indexing this document:  
curl -XPUT [http://localhost:9200/index/xxx/1](http://localhost:9200/index/xxx/1) -d '{"yyy": {field1:  
"test1", field3: "test3"}}'

Exception is:  
org.elasticsearch.index.mapper.MapperParsingException: Mapping must  
have the `type` as the root object  
at  
org.elasticsearch.index.mapper.xcontent.XContentDocumentMapperParser.extractMapping(XContentDocumentMapperParser.java:  
235)  
at  
org.elasticsearch.index.mapper.xcontent.XContentDocumentMapperParser.parse(XContentDocumentMapperParser.java:  
106)  
at  
org.elasticsearch.index.mapper.xcontent.XContentDocumentMapperParser.parse(XContentDocumentMapperParser.java:  
46)

When working with a single object in the dynamic-mapping.json it works  
OK.  
Another thing we tried is using the config/mappings/\_default folder to  
achieve this (created two files called aaa.json and xxx.json with the  
relevant content in each file). This resulted in a response from  
elastic search:  
{"error":"nested: "}  
without an exception on ES.

BTW, in the documentation, it says that the file name is dynamic-  
mapping.json ([http://www.elasticsearch.com/docs/elasticsearch/mapping/](http://www.elasticsearch.com/docs/elasticsearch/mapping/)  
dynamic\_mapping/). We also saw a reference to this file in the code.  
In one of the bug fixes ([http://github.com/elasticsearch/elasticsearch/](http://github.com/elasticsearch/elasticsearch/)  
issues/closed#issue/275) it says that the file is now called default-  
mapping.json or is this a different file? Which should be used for  
what?

Thanks,  
Tal

---

<div class="post-metadata">

**Author:** ![James\_Cook](https://avatars.discourse-cdn.com/v4/letter/j/898d66/32.png) [@James\_Cook](https://discuss.elastic.co/u/James_Cook)\
**Post date:** [July 29, 2010, 1:32pm UTC](https://discuss.elastic.co/t/problem-with-dynamic-mapping-json/3170/2 "2010-07-29T13:32:32Z")

</div>

This was refactored heavily in 0.9.0. What version are you using?

-- jim

On Thu, Jul 29, 2010 at 7:25 AM, Tal [talsalmona@gmail.com](mailto:talsalmona@gmail.com) wrote:

> Hi,
> 
> We are working on a system that requires each tenant to have their own  
> index. Each index may have multiple object types (in the example  
> below: aaa and xxx). We need to control the field names so we wanted  
> to use the conf/dynamic-mapping.json file to define the field names in  
> advance.  
> We prefer to do this when the system is loaded instead of having to  
> redefine it for each tenant when it is created.
> 
> The dynamic-mapping.json includes two objects, like so:
> 
> {  
> "xxx" : {  
> "type" : "object",  
> "path" : "just\_name",  
> "properties" : {  
> "yyy" : {  
> "type" : "object",  
> "path" : "just\_name",  
> "properties" : {  
> "field3" : { "index\_name" : "f3", type: "string" },  
> "field1" : { "index\_name" : "f1", type: "string" }  
> }  
> }  
> }  
> },
> 
> "aaa" : {  
> "type" : "object",  
> "path" : "just\_name",  
> "properties" : {  
> "bbb" : {  
> "type" : "object",  
> "path" : "just\_name",  
> "properties" : {  
> "field2" : { "index\_name" : "f2", type: "string" },  
> "field1" : { "index\_name" : "f1", type: "string" }  
> }  
> }  
> }  
> }
> 
> }
> 
> When doing this, we get an exeption when indexing this document:  
> curl -XPUT [http://localhost:9200/index/xxx/1](http://localhost:9200/index/xxx/1) -d '{"yyy": {field1:  
> "test1", field3: "test3"}}'
> 
> Exception is:  
> org.elasticsearch.index.mapper.MapperParsingException: Mapping must  
> have the `type` as the root object  
> at
> 
> org.elasticsearch.index.mapper.xcontent.XContentDocumentMapperParser.extractMapping(XContentDocumentMapperParser.java:  
> 235)  
> at
> 
> org.elasticsearch.index.mapper.xcontent.XContentDocumentMapperParser.parse(XContentDocumentMapperParser.java:  
> 106)  
> at
> 
> org.elasticsearch.index.mapper.xcontent.XContentDocumentMapperParser.parse(XContentDocumentMapperParser.java:  
> 46)
> 
> When working with a single object in the dynamic-mapping.json it works  
> OK.  
> Another thing we tried is using the config/mappings/\_default folder to  
> achieve this (created two files called aaa.json and xxx.json with the  
> relevant content in each file). This resulted in a response from  
> Elasticsearch:  
> {"error":"nested: "}  
> without an exception on ES.
> 
> BTW, in the documentation, it says that the file name is dynamic-  
> mapping.json ([http://www.elasticsearch.com/docs/elasticsearch/mapping/](http://www.elasticsearch.com/docs/elasticsearch/mapping/)  
> dynamic\_mapping/). We also saw a reference to this file in the code.  
> In one of the bug fixes ([GitHub - elastic/elasticsearch: Free and Open, Distributed, RESTful Search Engine](http://github.com/elasticsearch/elasticsearch/)  
> issues/closed#issue/275) it says that the file is now called default-  
> mapping.json or is this a different file? Which should be used for  
> what?
> 
> Thanks,  
> Tal

---

<div class="post-metadata">

**Author:** ![talsalmona](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/talsalmona/32/3316_2.png) [@talsalmona](https://discuss.elastic.co/u/talsalmona)\
**Post date:** [July 29, 2010, 2:31pm UTC](https://discuss.elastic.co/t/problem-with-dynamic-mapping-json/3170/3 "2010-07-29T14:31:19Z")

</div>

0.9.0

On Jul 29, 4:32 pm, James Cook [jc...@tracermedia.com](mailto:jc...@tracermedia.com) wrote:

> This was refactored heavily in 0.9.0. What version are you using?
> 
> -- jim
> 
> On Thu, Jul 29, 2010 at 7:25 AM, Tal [talsalm...@gmail.com](mailto:talsalm...@gmail.com) wrote:
> 
> > Hi,
> 
> > We are working on a system that requires each tenant to have their own  
> > index. Each index may have multiple object types (in the example  
> > below: aaa and xxx). We need to control the field names so we wanted  
> > to use the conf/dynamic-mapping.json file to define the field names in  
> > advance.  
> > We prefer to do this when the system is loaded instead of having to  
> > redefine it for each tenant when it is created.
> 
> > The dynamic-mapping.json includes two objects, like so:
> 
> > {  
> > "xxx" : {  
> > "type" : "object",  
> > "path" : "just\_name",  
> > "properties" : {  
> > "yyy" : {  
> > "type" : "object",  
> > "path" : "just\_name",  
> > "properties" : {  
> > "field3" : { "index\_name" : "f3", type: "string" },  
> > "field1" : { "index\_name" : "f1", type: "string" }  
> > }  
> > }  
> > }  
> > },
> 
> > "aaa" : {  
> > "type" : "object",  
> > "path" : "just\_name",  
> > "properties" : {  
> > "bbb" : {  
> > "type" : "object",  
> > "path" : "just\_name",  
> > "properties" : {  
> > "field2" : { "index\_name" : "f2", type: "string" },  
> > "field1" : { "index\_name" : "f1", type: "string" }  
> > }  
> > }  
> > }  
> > }
> 
> > }
> 
> > When doing this, we get an exeption when indexing this document:  
> > curl -XPUThttp://localhost:9200/index/xxx/1-d '{"yyy": {field1:  
> > "test1", field3: "test3"}}'
> 
> > Exception is:  
> > org.elasticsearch.index.mapper.MapperParsingException: Mapping must  
> > have the `type` as the root object  
> > at
> 
> > org.elasticsearch.index.mapper.xcontent.XContentDocumentMapperParser.extractMapping(XContentDocumentMapperParser.java:  
> > 235)  
> > at
> 
> > org.elasticsearch.index.mapper.xcontent.XContentDocumentMapperParser.parse(XContentDocumentMapperParser.java:  
> > 106)  
> > at
> 
> > org.elasticsearch.index.mapper.xcontent.XContentDocumentMapperParser.parse(XContentDocumentMapperParser.java:  
> > 46)
> 
> > When working with a single object in the dynamic-mapping.json it works  
> > OK.  
> > Another thing we tried is using the config/mappings/\_default folder to  
> > achieve this (created two files called aaa.json and xxx.json with the  
> > relevant content in each file). This resulted in a response from  
> > Elasticsearch:  
> > {"error":"nested: "}  
> > without an exception on ES.
> 
> > BTW, in the documentation, it says that the file name is dynamic-  
> > mapping.json ([http://www.elasticsearch.com/docs/elasticsearch/mapping/](http://www.elasticsearch.com/docs/elasticsearch/mapping/)  
> > dynamic\_mapping/). We also saw a reference to this file in the code.  
> > In one of the bug fixes ([GitHub - elastic/elasticsearch: Free and Open, Distributed, RESTful Search Engine](http://github.com/elasticsearch/elasticsearch/)  
> > issues/closed#issue/275) it says that the file is now called default-  
> > mapping.json or is this a different file? Which should be used for  
> > what?
> 
> > Thanks,  
> > Tal

---

<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:** [July 29, 2010, 5:27pm UTC](https://discuss.elastic.co/t/problem-with-dynamic-mapping-json/3170/4 "2010-07-29T17:27:33Z")

</div>

In 0.9, the name was changed to default-mapping.json, check the docs for it  
here:  
[http://www.elasticsearch.com/docs/elasticsearch/mapping/dynamic\_mapping/](http://www.elasticsearch.com/docs/elasticsearch/mapping/dynamic_mapping/).  
Also note that you can only place single "_default_" mapping as it applies  
to type level mappings created (for example, by put\_mapping).

I think what you want is covered here:  
[http://www.elasticsearch.com/docs/elasticsearch/mapping/builtin\_mappings/](http://www.elasticsearch.com/docs/elasticsearch/mapping/builtin_mappings/),  
which is the ability to predefine mappings for indices when they are  
created.

-shay.banon

On Thu, Jul 29, 2010 at 5:31 PM, Tal [talsalmona@gmail.com](mailto:talsalmona@gmail.com) wrote:

> 0.9.0
> 
> On Jul 29, 4:32 pm, James Cook [jc...@tracermedia.com](mailto:jc...@tracermedia.com) wrote:
> 
> > This was refactored heavily in 0.9.0. What version are you using?
> > 
> > -- jim
> > 
> > On Thu, Jul 29, 2010 at 7:25 AM, Tal [talsalm...@gmail.com](mailto:talsalm...@gmail.com) wrote:
> > 
> > > Hi,
> > 
> > > We are working on a system that requires each tenant to have their own  
> > > index. Each index may have multiple object types (in the example  
> > > below: aaa and xxx). We need to control the field names so we wanted  
> > > to use the conf/dynamic-mapping.json file to define the field names in  
> > > advance.  
> > > We prefer to do this when the system is loaded instead of having to  
> > > redefine it for each tenant when it is created.
> > 
> > > The dynamic-mapping.json includes two objects, like so:
> > 
> > > {  
> > > "xxx" : {  
> > > "type" : "object",  
> > > "path" : "just\_name",  
> > > "properties" : {  
> > > "yyy" : {  
> > > "type" : "object",  
> > > "path" : "just\_name",  
> > > "properties" : {  
> > > "field3" : { "index\_name" : "f3", type: "string" },  
> > > "field1" : { "index\_name" : "f1", type: "string" }  
> > > }  
> > > }  
> > > }  
> > > },
> > 
> > > "aaa" : {  
> > > "type" : "object",  
> > > "path" : "just\_name",  
> > > "properties" : {  
> > > "bbb" : {  
> > > "type" : "object",  
> > > "path" : "just\_name",  
> > > "properties" : {  
> > > "field2" : { "index\_name" : "f2", type: "string" },  
> > > "field1" : { "index\_name" : "f1", type: "string" }  
> > > }  
> > > }  
> > > }  
> > > }
> > 
> > > }
> > 
> > > When doing this, we get an exeption when indexing this document:  
> > > curl -XPUThttp://localhost:9200/index/xxx/1-d '{"yyy": {field1:  
> > > "test1", field3: "test3"}}'
> > 
> > > Exception is:  
> > > org.elasticsearch.index.mapper.MapperParsingException: Mapping must  
> > > have the `type` as the root object  
> > > at
> > 
> > >
> 
> org.elasticsearch.index.mapper.xcontent.XContentDocumentMapperParser.extractMapping(XContentDocumentMapperParser.java:
> 
> > > 1. at
> > 
> > >
> 
> org.elasticsearch.index.mapper.xcontent.XContentDocumentMapperParser.parse(XContentDocumentMapperParser.java:
> 
> > > 1. at
> > 
> > >
> 
> org.elasticsearch.index.mapper.xcontent.XContentDocumentMapperParser.parse(XContentDocumentMapperParser.java:
> 
> > > 1.
> > 
> > > When working with a single object in the dynamic-mapping.json it works  
> > > OK.  
> > > Another thing we tried is using the config/mappings/\_default folder to  
> > > achieve this (created two files called aaa.json and xxx.json with the  
> > > relevant content in each file). This resulted in a response from  
> > > Elasticsearch:  
> > > {"error":"nested: "}  
> > > without an exception on ES.
> > 
> > > BTW, in the documentation, it says that the file name is dynamic-  
> > > mapping.json ([http://www.elasticsearch.com/docs/elasticsearch/mapping/](http://www.elasticsearch.com/docs/elasticsearch/mapping/)  
> > > dynamic\_mapping/). We also saw a reference to this file in the code.  
> > > In one of the bug fixes (  
> > > [GitHub - elastic/elasticsearch: Free and Open, Distributed, RESTful Search Engine](http://github.com/elasticsearch/elasticsearch/)  
> > > issues/closed#issue/275) it says that the file is now called default-  
> > > mapping.json or is this a different file? Which should be used for  
> > > what?
> > 
> > > Thanks,  
> > > Tal

---

<div class="post-metadata">

**Author:** ![talsalmona](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/talsalmona/32/3316_2.png) [@talsalmona](https://discuss.elastic.co/u/talsalmona)\
**Post date:** [July 30, 2010, 1:58pm UTC](https://discuss.elastic.co/t/problem-with-dynamic-mapping-json/3170/5 "2010-07-30T13:58:19Z")

</div>

In the example above I also tried to create a file called xxx.json and  
put it in the config/mappings/\_default folder with the following  
content:

{  
"xxx" : {  
"type" : "object",  
"path" : "just\_name",  
"properties" : {  
"yyy" : {  
"type" : "object",  
"path" : "just\_name",  
"properties" : {  
"field3" : { "index\_name" : "f3", type: "string" },  
"field1" : { "index\_name" : "f1", type: "string" }  
}  
}  
}  
}  
}

but when I indexed the following:  
curl -XPUT [http://localhost:9200/index/xxx/1](http://localhost:9200/index/xxx/1) -d '{"yyy":  
{field1:"test1", field3: "test3"}}'

I get the following response: {"error":"nested: "}  
Nothing is printed in the elastic search log.

---

<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:** [July 30, 2010, 3:58pm UTC](https://discuss.elastic.co/t/problem-with-dynamic-mapping-json/3170/6 "2010-07-30T15:58:29Z")

</div>

Maybe its because you put `yyy` in the json you want to index for `xxx`?  
Seems like you are getting an internal null pointer exception in  
elasticsearch, what are the exact steps you created it? I will try and  
recreate it and get a better error message.

-shay.banon

On Fri, Jul 30, 2010 at 4:58 PM, Tal [talsalmona@gmail.com](mailto:talsalmona@gmail.com) wrote:

> In the example above I also tried to create a file called xxx.json and  
> put it in the config/mappings/\_default folder with the following  
> content:
> 
> {  
> "xxx" : {  
> "type" : "object",  
> "path" : "just\_name",  
> "properties" : {  
> "yyy" : {  
> "type" : "object",  
> "path" : "just\_name",  
> "properties" : {  
> "field3" : { "index\_name" : "f3", type: "string" },  
> "field1" : { "index\_name" : "f1", type: "string" }  
> }  
> }  
> }  
> }  
> }
> 
> but when I indexed the following:  
> curl -XPUT [http://localhost:9200/index/xxx/1](http://localhost:9200/index/xxx/1) -d '{"yyy":  
> {field1:"test1", field3: "test3"}}'
> 
> I get the following response: {"error":"nested: "}  
> Nothing is printed in the Elasticsearch log.

---

<div class="post-metadata">

**Author:** ![talsalmona](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/talsalmona/32/3316_2.png) [@talsalmona](https://discuss.elastic.co/u/talsalmona)\
**Post date:** [July 30, 2010, 7:25pm UTC](https://discuss.elastic.co/t/problem-with-dynamic-mapping-json/3170/7 "2010-07-30T19:25:07Z")

</div>

I thought the root element of the xxx.json should be xxx (the same as  
it would have been had it been placed in the conf/default-  
mapping.json).  
I also tried modifying the file by putting "yyy" as the root element  
but I get the same error.

Here are the steps to reproduce:

1. Create a file conf/mappings/\_default/xxx.json with the following  
content:  
"yyy" : {  
"type" : "object",  
"path" : "just\_name",  
"properties" : {  
"field3" : { "index\_name" : "f3", type: "string" },  
"field1" : { "index\_name" : "f1", type: "string" }  
}  
}

2. Try indexing the following document by running curl:  
curl -XPUT [http://localhost:9200/index/xxx/1](http://localhost:9200/index/xxx/1) -d '{"yyy":  
{field1:"test1", field3: "test3"}}'

## ==\> Expected result:

a. Document is indexed and the dynamic mapping of the xxx type is  
unaffected (remains according to the definition in xxx.json)  
b. the query string "f1:test1" should return the document.

## Actual result:

Elastic Search returns:  
{"error":"nested: "}

No error is logged in the Elasticsearch log file.

Thanks,  
Tal

On Jul 30, 6:58 pm, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:

> Maybe its because you put `yyy` in the json you want to index for `xxx`?  
> Seems like you are getting an internal null pointer exception in  
> elasticsearch, what are the exact steps you created it? I will try and  
> recreate it and get a better error message.
> 
> -shay.banon
> 
> On Fri, Jul 30, 2010 at 4:58 PM, Tal [talsalm...@gmail.com](mailto:talsalm...@gmail.com) wrote:
> 
> > In the example above I also tried to create a file called xxx.json and  
> > put it in the config/mappings/\_default folder with the following  
> > content:
> 
> > {  
> > "xxx" : {  
> > "type" : "object",  
> > "path" : "just\_name",  
> > "properties" : {  
> > "yyy" : {  
> > "type" : "object",  
> > "path" : "just\_name",  
> > "properties" : {  
> > "field3" : { "index\_name" : "f3", type: "string" },  
> > "field1" : { "index\_name" : "f1", type: "string" }  
> > }  
> > }  
> > }  
> > }  
> > }
> 
> > but when I indexed the following:  
> > curl -XPUThttp://localhost:9200/index/xxx/1-d '{"yyy":  
> > {field1:"test1", field3: "test3"}}'
> 
> > I get the following response: {"error":"nested: "}  
> > Nothing is printed in the Elasticsearch log.

---

<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:** [July 30, 2010, 7:44pm UTC](https://discuss.elastic.co/t/problem-with-dynamic-mapping-json/3170/8 "2010-07-30T19:44:40Z")

</div>

Strange, I followed the mentioned steps, and did not get a problem. Though,  
there are some misunderstandings:

1. When you create a file called xxx.json, then the type should also be xxx,  
and not yyy (within the json).
2. You should place it under config/mappings/\_default, and not  
conf/mappings/\_default
3. When you index something under the type xxx, then the content should be  
under xxx, and not with yyy as you indexed.
4. Not related, but I don't think you need the just\_name path, it rarely  
needs to be set.

-shay.banon

On Fri, Jul 30, 2010 at 10:25 PM, Tal [talsalmona@gmail.com](mailto:talsalmona@gmail.com) wrote:

> I thought the root element of the xxx.json should be xxx (the same as  
> it would have been had it been placed in the conf/default-  
> mapping.json).  
> I also tried modifying the file by putting "yyy" as the root element  
> but I get the same error.
> 
> Here are the steps to reproduce:
> 
> 1. Create a file conf/mappings/\_default/xxx.json with the following  
> content:  
> "yyy" : {  
> "type" : "object",  
> "path" : "just\_name",  
> "properties" : {  
> "field3" : { "index\_name" : "f3", type: "string" },  
> "field1" : { "index\_name" : "f1", type: "string" }  
> }  
> }
> 
> 2. Try indexing the following document by running curl:  
> curl -XPUT [http://localhost:9200/index/xxx/1](http://localhost:9200/index/xxx/1) -d '{"yyy":  
> {field1:"test1", field3: "test3"}}'
> 
> ## ==\> Expected result:
> 
> a. Document is indexed and the dynamic mapping of the xxx type is  
> unaffected (remains according to the definition in xxx.json)  
> b. the query string "f1:test1" should return the document.
> 
> ## Actual result:
> 
> Elastic Search returns:  
> {"error":"nested: "}
> 
> No error is logged in the Elasticsearch log file.
> 
> Thanks,  
> Tal
> 
> On Jul 30, 6:58 pm, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> 
> > Maybe its because you put `yyy` in the json you want to index for `xxx`?  
> > Seems like you are getting an internal null pointer exception in  
> > elasticsearch, what are the exact steps you created it? I will try and  
> > recreate it and get a better error message.
> > 
> > -shay.banon
> > 
> > On Fri, Jul 30, 2010 at 4:58 PM, Tal [talsalm...@gmail.com](mailto:talsalm...@gmail.com) wrote:
> > 
> > > In the example above I also tried to create a file called xxx.json and  
> > > put it in the config/mappings/\_default folder with the following  
> > > content:
> > 
> > > {  
> > > "xxx" : {  
> > > "type" : "object",  
> > > "path" : "just\_name",  
> > > "properties" : {  
> > > "yyy" : {  
> > > "type" : "object",  
> > > "path" : "just\_name",  
> > > "properties" : {  
> > > "field3" : { "index\_name" : "f3", type: "string" },  
> > > "field1" : { "index\_name" : "f1", type: "string" }  
> > > }  
> > > }  
> > > }  
> > > }  
> > > }
> > 
> > > but when I indexed the following:  
> > > curl -XPUThttp://localhost:9200/index/xxx/1-d '{"yyy":  
> > > {field1:"test1", field3: "test3"}}'
> > 
> > > I get the following response: {"error":"nested: "}  
> > > Nothing is printed in the Elasticsearch log.

---

<div class="post-metadata">

**Author:** ![talsalmona](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/talsalmona/32/3316_2.png) [@talsalmona](https://discuss.elastic.co/u/talsalmona)\
**Post date:** [July 30, 2010, 9:02pm UTC](https://discuss.elastic.co/t/problem-with-dynamic-mapping-json/3170/9 "2010-07-30T21:02:43Z")

</div>

Maybe the terminology is wrong.  
I thought that when I do something like this:  
curl -XPUT [http://localhost:9200/abc/xyz/1](http://localhost:9200/abc/xyz/1) -d ........  
then the "index" is "abc" and the "type" is "xyz".

In my example above I'm using the url [http://localhost:9200/index/xxx](http://localhost:9200/index/xxx)  
so the type IS "xxx"  
Anyway, I tried to wrap the json I'm sending with an "xxx" object like  
so:

{  
"xxx": {  
"yyy" : {  
"type" : "object",  
"path" : "just\_name",  
"properties" : {  
"field3" : { "index\_name" : "f3", "type": "string" },  
"field1" : { "index\_name" : "f1", "type": "string" }  
}  
}  
}  
}

But still getting the same problem.  
Tried to run this on Win Vista and on Ubuntu.

Regarding the placement of the file, I was wrong in my post. I did  
place it under config/mappings/\_default.

Regarding "just\_name", what I'm trying to achieve is to be able to  
refer to properties in a simple way without the full path since my  
objects are complex (in real life, not in this example).  
In the example above I'd expect to be able to find the document by  
searching for "f1:test1" instead of "yyy.field1:test1"

Thanks,  
Tal

---

<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:** [July 30, 2010, 11:40pm UTC](https://discuss.elastic.co/t/problem-with-dynamic-mapping-json/3170/10 "2010-07-30T23:40:15Z")

</div>

So in your case, yyy is an object within the xxx type? Something like:

{  
xxx : {  
yyy : {  
field1 : "value"  
}  
}  
}

In this case, you need to have it defined within properties of xxx mapping  
definition. Check this example:  
[http://www.elasticsearch.com/docs/elasticsearch/mapping/object\_type/](http://www.elasticsearch.com/docs/elasticsearch/mapping/object_type/).

Strange that I can't recreate it..., you sure you are running with 0.9?

-shay.banon

On Sat, Jul 31, 2010 at 12:02 AM, Tal [talsalmona@gmail.com](mailto:talsalmona@gmail.com) wrote:

> Maybe the terminology is wrong.  
> I thought that when I do something like this:  
> curl -XPUT [http://localhost:9200/abc/xyz/1](http://localhost:9200/abc/xyz/1) -d ........  
> then the "index" is "abc" and the "type" is "xyz".
> 
> In my example above I'm using the url [http://localhost:9200/index/xxx](http://localhost:9200/index/xxx)  
> so the type IS "xxx"  
> Anyway, I tried to wrap the json I'm sending with an "xxx" object like  
> so:
> 
> {  
> "xxx": {  
> "yyy" : {  
> "type" : "object",  
> "path" : "just\_name",  
> "properties" : {  
> "field3" : { "index\_name" : "f3", "type": "string" },  
> "field1" : { "index\_name" : "f1", "type": "string" }  
> }  
> }  
> }  
> }
> 
> But still getting the same problem.  
> Tried to run this on Win Vista and on Ubuntu.
> 
> Regarding the placement of the file, I was wrong in my post. I did  
> place it under config/mappings/\_default.
> 
> Regarding "just\_name", what I'm trying to achieve is to be able to  
> refer to properties in a simple way without the full path since my  
> objects are complex (in real life, not in this example).  
> In the example above I'd expect to be able to find the document by  
> searching for "f1:test1" instead of "yyy.field1:test1"
> 
> Thanks,  
> Tal

---

<div class="post-metadata">

**Author:** ![talsalmona](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/talsalmona/32/3316_2.png) [@talsalmona](https://discuss.elastic.co/u/talsalmona)\
**Post date:** [July 31, 2010, 6:57am UTC](https://discuss.elastic.co/t/problem-with-dynamic-mapping-json/3170/11 "2010-07-31T06:57:00Z")

</div>

Yes, yyy is an object within the xxx type.

I'm using 0.9.0.

Here is my config folder:  
[https://docs.google.com/leaf?id=0B68WZXvnkGUTMjJmODFiMDMtYWY0OS00OTJhLWI3Y2EtZTNjZTQzM2QwOTFh&sort=name&layout=list&num=50](https://docs.google.com/leaf?id=0B68WZXvnkGUTMjJmODFiMDMtYWY0OS00OTJhLWI3Y2EtZTNjZTQzM2QwOTFh&sort=name&layout=list&num=50)

This is the call I'm doing:  
curl -XPUT [http://localhost:9200/index/xxx/1](http://localhost:9200/index/xxx/1) -d '{"yyy":  
{field1:"test1", field3: "test3"}}'

Thanks,  
Tal

---

<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:** [July 31, 2010, 7:41am UTC](https://discuss.elastic.co/t/problem-with-dynamic-mapping-json/3170/12 "2010-07-31T07:41:58Z")

</div>

Can get the document you link to.

In any case, I also noted the mapping change you need to make (based no the  
last mapping you attached). The mapping for "yyy" needs to come under  
properties. Check the link I sent (  
[http://www.elasticsearch.com/docs/elasticsearch/mapping/object\_type/](http://www.elasticsearch.com/docs/elasticsearch/mapping/object_type/)), where  
tweet in the type and "person" is the inner object. Tweet maps to "xxx" in  
our case, and "person" maps to "yyy.

-shay.banon

On Sat, Jul 31, 2010 at 9:57 AM, Tal [talsalmona@gmail.com](mailto:talsalmona@gmail.com) wrote:

> Yes, yyy is an object within the xxx type.
> 
> I'm using 0.9.0.
> 
> Here is my config folder:
> 
> [config.tar.gz - Google Drive](https://docs.google.com/leaf?id=0B68WZXvnkGUTMjJmODFiMDMtYWY0OS00OTJhLWI3Y2EtZTNjZTQzM2QwOTFh&sort=name&layout=list&num=50)
> 
> This is the call I'm doing:  
> curl -XPUT [http://localhost:9200/index/xxx/1](http://localhost:9200/index/xxx/1) -d '{"yyy":  
> {field1:"test1", field3: "test3"}}'
> 
> Thanks,  
> Tal

---

<div class="post-metadata">

**Author:** ![talsalmona](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/talsalmona/32/3316_2.png) [@talsalmona](https://discuss.elastic.co/u/talsalmona)\
**Post date:** [July 31, 2010, 8:34am UTC](https://discuss.elastic.co/t/problem-with-dynamic-mapping-json/3170/13 "2010-07-31T08:34:26Z")

</div>

Try again, the attachment should be accessible now.

> **[config.tar.gz](https://drive.google.com/file/d/0B68WZXvnkGUTMjJmODFiMDMtYWY0OS00OTJhLWI3Y2EtZTNjZTQzM2QwOTFh/view?usp=drive_open&sort=name&layout=list&num=50&pli=1&authkey=CIr9w4MN)**
>
> Google Drive file.

Thanks,  
Tal

On Jul 31, 10:41 am, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:

> Can get the document you link to.
> 
> In any case, I also noted the mapping change you need to make (based no the  
> last mapping you attached). The mapping for "yyy" needs to come under  
> properties. Check the link I sent ([http://www.elasticsearch.com/docs/elasticsearch/mapping/object\_type/](http://www.elasticsearch.com/docs/elasticsearch/mapping/object_type/)), where  
> tweet in the type and "person" is the inner object. Tweet maps to "xxx" in  
> our case, and "person" maps to "yyy.
> 
> -shay.banon
> 
> On Sat, Jul 31, 2010 at 9:57 AM, Tal [talsalm...@gmail.com](mailto:talsalm...@gmail.com) wrote:
> 
> > Yes, yyy is an object within the xxx type.
> 
> > I'm using 0.9.0.
> 
> > Here is my config folder:
> 
> > [https://docs.google.com/leaf?id=0B68WZXvnkGUTMjJmODFiMDMtYWY0OS00OTJh](https://docs.google.com/leaf?id=0B68WZXvnkGUTMjJmODFiMDMtYWY0OS00OTJh)...
> 
> > This is the call I'm doing:  
> > curl -XPUThttp://localhost:9200/index/xxx/1-d '{"yyy":  
> > {field1:"test1", field3: "test3"}}'
> 
> > Thanks,  
> > Tal

---

<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:** [July 31, 2010, 12:45pm UTC](https://discuss.elastic.co/t/problem-with-dynamic-mapping-json/3170/14 "2010-07-31T12:45:42Z")

</div>

Hi,

Ok, managed to recreate this. The first problem is that the json you  
provided in the mappings (xxx.json) is malformed. The second problem (and  
its something I fixed post 0.9.0) was wrong handling of the  
config/mappings/[index\_name] causing an NPE. I fixed it in master (will be  
part of 0.9.1). Someone on the mailing list spotted that a week or so ago.  
Here is the issue:  
[Mapper: Wrong check for `config/mappings/[index_name]` causing failure to create index · Issue #284 · elastic/elasticsearch · GitHub](http://github.com/elasticsearch/elasticsearch/issues/issue/284).

-shay.banon

On Sat, Jul 31, 2010 at 11:34 AM, Tal [talsalmona@gmail.com](mailto:talsalmona@gmail.com) wrote:

> Try again, the attachment should be accessible now.
> 
> [config.tar.gz - Google Drive](https://docs.google.com/leaf?id=0B68WZXvnkGUTMjJmODFiMDMtYWY0OS00OTJhLWI3Y2EtZTNjZTQzM2QwOTFh&sort=name&layout=list&num=50&pli=1&authkey=CIr9w4MN)
> 
> Thanks,  
> Tal
> 
> On Jul 31, 10:41 am, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> 
> > Can get the document you link to.
> > 
> > In any case, I also noted the mapping change you need to make (based no  
> > the  
> > last mapping you attached). The mapping for "yyy" needs to come under  
> > properties. Check the link I sent (  
> > [http://www.elasticsearch.com/docs/elasticsearch/mapping/object\_type/](http://www.elasticsearch.com/docs/elasticsearch/mapping/object_type/)),  
> > where  
> > tweet in the type and "person" is the inner object. Tweet maps to "xxx"  
> > in  
> > our case, and "person" maps to "yyy.
> > 
> > -shay.banon
> > 
> > On Sat, Jul 31, 2010 at 9:57 AM, Tal [talsalm...@gmail.com](mailto:talsalm...@gmail.com) wrote:
> > 
> > > Yes, yyy is an object within the xxx type.
> > 
> > > I'm using 0.9.0.
> > 
> > > Here is my config folder:
> > 
> > > [https://docs.google.com/leaf?id=0B68WZXvnkGUTMjJmODFiMDMtYWY0OS00OTJh](https://docs.google.com/leaf?id=0B68WZXvnkGUTMjJmODFiMDMtYWY0OS00OTJh).  
> > > ..
> > 
> > > This is the call I'm doing:  
> > > curl -XPUThttp://localhost:9200/index/xxx/1-d '{"yyy":  
> > > {field1:"test1", field3: "test3"}}'
> > 
> > > Thanks,  
> > > Tal

---

<div class="post-metadata">

**Author:** ![talsalmona](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/talsalmona/32/3316_2.png) [@talsalmona](https://discuss.elastic.co/u/talsalmona)\
**Post date:** [July 31, 2010, 12:56pm UTC](https://discuss.elastic.co/t/problem-with-dynamic-mapping-json/3170/15 "2010-07-31T12:56:16Z")

</div>

Thanks,  
I'll try to rebuild from master.

Tal

On Jul 31, 3:45 pm, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:

> Hi,
> 
> Ok, managed to recreate this. The first problem is that the json you  
> provided in the mappings (xxx.json) is malformed. The second problem (and  
> its something I fixed post 0.9.0) was wrong handling of the  
> config/mappings/[index\_name] causing an NPE. I fixed it in master (will be  
> part of 0.9.1). Someone on the mailing list spotted that a week or so ago.  
> Here is the issue:[Mapper: Wrong check for `config/mappings/[index_name]` causing failure to create index · Issue #284 · elastic/elasticsearch · GitHub](http://github.com/elasticsearch/elasticsearch/issues/issue/284).
> 
> -shay.banon
> 
> On Sat, Jul 31, 2010 at 11:34 AM, Tal [talsalm...@gmail.com](mailto:talsalm...@gmail.com) wrote:
> 
> > Try again, the attachment should be accessible now.
> 
> > [https://docs.google.com/leaf?id=0B68WZXvnkGUTMjJmODFiMDMtYWY0OS00OTJh](https://docs.google.com/leaf?id=0B68WZXvnkGUTMjJmODFiMDMtYWY0OS00OTJh)...
> 
> > Thanks,  
> > Tal
> 
> > On Jul 31, 10:41 am, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> > 
> > > Can get the document you link to.
> 
> > > In any case, I also noted the mapping change you need to make (based no  
> > > the  
> > > last mapping you attached). The mapping for "yyy" needs to come under  
> > > properties. Check the link I sent (  
> > > [http://www.elasticsearch.com/docs/elasticsearch/mapping/object\_type/](http://www.elasticsearch.com/docs/elasticsearch/mapping/object_type/)),  
> > > where  
> > > tweet in the type and "person" is the inner object. Tweet maps to "xxx"  
> > > in  
> > > our case, and "person" maps to "yyy.
> 
> > > -shay.banon
> 
> > > On Sat, Jul 31, 2010 at 9:57 AM, Tal [talsalm...@gmail.com](mailto:talsalm...@gmail.com) wrote:
> > > 
> > > > Yes, yyy is an object within the xxx type.
> 
> > > > I'm using 0.9.0.
> 
> > > > Here is my config folder:
> 
> > > > [https://docs.google.com/leaf?id=0B68WZXvnkGUTMjJmODFiMDMtYWY0OS00OTJh](https://docs.google.com/leaf?id=0B68WZXvnkGUTMjJmODFiMDMtYWY0OS00OTJh).  
> > > > ..
> 
> > > > This is the call I'm doing:  
> > > > curl -XPUThttp://localhost:9200/index/xxx/1-d'{"yyy":  
> > > > {field1:"test1", field3: "test3"}}'
> 
> > > > Thanks,  
> > > > Tal

---

<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:21am UTC](https://discuss.elastic.co/t/problem-with-dynamic-mapping-json/3170/16 "2017-07-06T04:21:19Z")

</div>


