# What happens when multiple users index into same index and type with same document ids?

**URL:** <https://discuss.elastic.co/t/what-happens-when-multiple-users-index-into-same-index-and-type-with-same-document-ids/104144>\
**Category:** Elasticsearch\
**Created:** [October 16, 2017, 9:24pm UTC](https://discuss.elastic.co/t/what-happens-when-multiple-users-index-into-same-index-and-type-with-same-document-ids/104144 "2017-10-16T21:24:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sramalin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sramalin/32/25821_2.png) [@sramalin](https://discuss.elastic.co/u/sramalin)\
**Post date:** [October 16, 2017, 9:24pm UTC](https://discuss.elastic.co/t/what-happens-when-multiple-users-index-into-same-index-and-type-with-same-document-ids/104144/1 "2017-10-16T21:24:21Z")

</div>

All,

I am curious to know what happens in the following case,  
Two users indexing into  
same index, say Index1  
same type, say Type1  
and they both try to index a document specifying the same id say id1.

What happens in this case? How does this scale out?

Thanks

---

<div class="post-metadata">

**Author:** ![mujtabahussain](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mujtabahussain/32/17514_2.png) [@mujtabahussain](https://discuss.elastic.co/u/mujtabahussain)\
**Post date:** [October 16, 2017, 10:57pm UTC](https://discuss.elastic.co/t/what-happens-when-multiple-users-index-into-same-index-and-type-with-same-document-ids/104144/2 "2017-10-16T22:57:04Z")

</div>

There will be a collision and you will get version conflict error. 🙂

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [October 17, 2017, 1:19am UTC](https://discuss.elastic.co/t/what-happens-when-multiple-users-index-into-same-index-and-type-with-same-document-ids/104144/3 "2017-10-17T01:19:28Z")

</div>

Not exactly. Not by default.

The last write operation will win and will overwrite the previous one.

If you want to have optimistic locking, add the expected version number as explained here: [https://www.elastic.co/guide/en/elasticsearch/reference/5.6/docs-index\_.html#index-versioning](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/docs-index_.html#index-versioning)

---

<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:** [November 14, 2017, 1:20am UTC](https://discuss.elastic.co/t/what-happens-when-multiple-users-index-into-same-index-and-type-with-same-document-ids/104144/4 "2017-11-14T01:20:05Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
