Indexing root objects

Hi all.

I have a quick newbie question. According to
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 :wink:

-cork

--

Hi Cork

I have a quick newbie question. According to
Elasticsearch Platform — Find real-time answers at scale | Elastic, 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

--

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,
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

--