Difference between index and create in bulk API?


(Sam-4) #1

Hi

I have read following reference guide
http://www.elasticsearch.org/guide/reference/river/rabbitmq.html
where bulk API format define as:

{ "index" : { "_index" : "twitter", "_type" : "tweet", "_id" : "1" } }
{ "tweet" : { "text" : "this is a tweet" } }
{ "delete" : { "_index" : "twitter", "_type" : "tweet", "_id" :
"2" } }
{ "create" : { "_index" : "twitter", "_type" : "tweet", "_id" :
"1" } }
{ "tweet" : { "text" : "another tweet" } }

I have doubt regarding using both index and create because both having
same parameters,so please explain what is difference between index
and create,both are used for create index or other reason using both.
it is required to use both for create index or any one can used for
creating index.

Thanks


(Clinton Gormley) #2

Hi Same

I have read following reference guide
http://www.elasticsearch.org/guide/reference/river/rabbitmq.html
where bulk API format define as:

{ "index" : { "_index" : "twitter", "_type" : "tweet", "_id" : "1" } }
{ "tweet" : { "text" : "this is a tweet" } }
{ "delete" : { "_index" : "twitter", "_type" : "tweet", "_id" :
"2" } }
{ "create" : { "_index" : "twitter", "_type" : "tweet", "_id" :
"1" } }
{ "tweet" : { "text" : "another tweet" } }

I have doubt regarding using both index and create because both having
same parameters,so please explain what is difference between index
and create,both are used for create index or other reason using both.
it is required to use both for create index or any one can used for
creating index.

Neither is used to create an index (although they may do so as a
side-effect of inserting the first document into a new index).

"index" indexes a document. "create" only indexes a document if it
doesn't already exist. It used to be that "create" was faster if you
knew that your docs didn't already exist. But now, since versioning was
added, "index" performs as well as "create"

clint


(system) #3