Whats different with 'index' and 'create' of Bulk API


(Jason Zheng) #1

Hi all,

I tried Bulk API from the document as

{ "index" : { "_index" : "test", "_type" : "type1", "_id" : "1" } }
{ "field1" : "value1" }
{ "delete" : { "_index" : "test", "_type" : "type1", "_id" : "2" } }
{ "create" : { "_index" : "test", "_type" : "type1", "_id" : "3" } }
{ "field1" : "value3" }
{ "update" : {"_id" : "1", "_type" : "type1", "_index" : "index1"} }
{ "doc" : {"field2" : "value2"} }

I set action.auto_create_index: false in config/elasticsearch.yml, but I don't understand whats different with 'index' and 'create', because both of them, which the response returns as :

"error" : "IndexMissingException[[test] missing]"

Some one can explain it?

Jason


(Mark Walkom) #2

You can't create an index in a bulk request, you need to do it externally cause you have action.auto_create_index: false.


(Jason Zheng) #3

Hi Mark,

Thanks.

If the index exists, whats different with 'create' and 'index'?

Jason


(sandro) #4

See here:
https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html#operation-type

If you use create if a doc with that id already exists, if you use index it will create a document or update it if xisting.


(Jason Zheng) #5

Thanks you, its helpful


(system) #6