# Indexing root objects

**URL:** <https://discuss.elastic.co/t/indexing-root-objects/9321>\
**Category:** Elasticsearch\
**Created:** [October 11, 2012, 3:49pm UTC](https://discuss.elastic.co/t/indexing-root-objects/9321 "2012-10-11T15:49:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ephraim\_Mower](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ephraim_mower/32/2687_2.png) [@Ephraim\_Mower](https://discuss.elastic.co/u/Ephraim_Mower)\
**Post date:** [October 11, 2012, 3:49pm UTC](https://discuss.elastic.co/t/indexing-root-objects/9321/1 "2012-10-11T15:49:19Z")

</div>

Hi all.

I have a quick newbie question. According to  
[http://www.elasticsearch.org/guide/reference/mapping/root-object-type.html](http://www.elasticsearch.org/guide/reference/mapping/root-object-type.html),  
when indexing a root object "it is preferable to to use the document  
without the type explicitly set". I would think that it would be necessary  
if we want the associated mapping to be used. Is there an  
explanation/reason for this, or am I missing something fundamental?

Sorry if this is a goofy question 😉

-cork

--

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [October 11, 2012, 3:55pm UTC](https://discuss.elastic.co/t/indexing-root-objects/9321/2 "2012-10-11T15:55:42Z")

</div>

Hi Cork

> I have a quick newbie question. According to  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/root-object-type.html), when indexing a root object "it is preferable to to use the document without the type explicitly set". I would think that it would be necessary if we want the associated mapping to be used. Is there an explanation/reason for this, or am I missing something fundamental?

The difference is between this:

```
curl -XPUT 'http://127.0.0.1:9200/test/test/1' -d '
{
   "foo" : 1
}
'

```

and this:

```
curl -XPUT 'http://127.0.0.1:9200/test/test/1' -d '
{
    "test" : {
       "foo" : 1
    }
}
'

```

The first form is preferred.

clint

--

---

<div class="post-metadata">

**Author:** ![Ephraim\_Mower](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ephraim_mower/32/2687_2.png) [@Ephraim\_Mower](https://discuss.elastic.co/u/Ephraim_Mower)\
**Post date:** [October 11, 2012, 4:07pm UTC](https://discuss.elastic.co/t/indexing-root-objects/9321/3 "2012-10-11T16:07:37Z")

</div>

Thanks, Clint!

So if I understand correctly, since you've got the type in the URL,  
including the type name in the doc is superfluous. I'm using a .NET client  
and that stuff is abstracted away for me so I missed it.

-cork

On Thursday, October 11, 2012 11:56:06 AM UTC-4, Clinton Gormley wrote:

> Hi Cork
> 
> > I have a quick newbie question. According to
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/root-object-type.html),  
> when indexing a root object "it is preferable to to use the document  
> without the type explicitly set". I would think that it would be necessary  
> if we want the associated mapping to be used. Is there an  
> explanation/reason for this, or am I missing something fundamental?
> 
> The difference is between this:
> 
> ```
> curl -XPUT 'http://127.0.0.1:9200/test/test/1' -d ' 
> { 
> "foo" : 1 
> } 
> ' 
> 
> ```
> 
> and this:
> 
> ```
> curl -XPUT 'http://127.0.0.1:9200/test/test/1' -d ' 
> { 
> "test" : { 
> "foo" : 1 
> } 
> } 
> ' 
> 
> ```
> 
> The first form is preferred.
> 
> clint

--

---

<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, 3:09am UTC](https://discuss.elastic.co/t/indexing-root-objects/9321/4 "2017-07-06T03:09:18Z")

</div>


