What is faster: index or update with doc_as_upsert and detect_noop


(Anton Bogdanovich) #1

I have a parent-child document mapping and parent document have only one id field.
And I need to make sure that this parent document exists when I insert new child document.
It may or may not be already existing.

So I use Bulk API to insert a parent if it not exist and insert a child document in one request.

My Question is which method is faster: update with doc_as_upsert and detect_noop OR index new record with the same data that probably already exist:

{ update: { _index: 'index_name', _type: 'contact', _id: 25, _routing: 14}}
{ doc: { id: 25 }, doc_as_upsert: true, detect_noop: true }
{ index: { _index: 'index_name', _type: 'event', _routing: 14, _parent: 25}}
{ ... event document body ...}

OR

{ index: { _index: 'index_name', _type: 'contact', _id: 25, _routing: 14}}
{ id: 25 }
{ index: { _index: 'index_name', _type: 'event', _routing: 14, _parent: 25}}
{ ... event document body ...}


(system) #2