# What is faster: index or update with doc\_as\_upsert and detect\_noop

**URL:** <https://discuss.elastic.co/t/what-is-faster-index-or-update-with-doc-as-upsert-and-detect-noop/241>\
**Category:** Elasticsearch\
**Created:** [May 5, 2015, 5:24pm UTC](https://discuss.elastic.co/t/what-is-faster-index-or-update-with-doc-as-upsert-and-detect-noop/241 "2015-05-05T17:24:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anton\_Bogdanovich](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anton_bogdanovich/32/44922_2.png) [@Anton\_Bogdanovich](https://discuss.elastic.co/u/Anton_Bogdanovich)\
**Post date:** [May 5, 2015, 5:24pm UTC](https://discuss.elastic.co/t/what-is-faster-index-or-update-with-doc-as-upsert-and-detect-noop/241/1 "2015-05-05T17:24:12Z")

</div>

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 ...}

---

<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, 12:15am UTC](https://discuss.elastic.co/t/what-is-faster-index-or-update-with-doc-as-upsert-and-detect-noop/241/2 "2017-07-06T00:15:34Z")

</div>


