# Update Document Questions

**URL:** <https://discuss.elastic.co/t/update-document-questions/122609>\
**Category:** Elasticsearch\
**Created:** [March 5, 2018, 10:56pm UTC](https://discuss.elastic.co/t/update-document-questions/122609 "2018-03-05T22:56:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jonb32](https://avatars.discourse-cdn.com/v4/letter/j/c37758/32.png) [@Jonb32](https://discuss.elastic.co/u/Jonb32)\
**Post date:** [March 5, 2018, 10:56pm UTC](https://discuss.elastic.co/t/update-document-questions/122609/1 "2018-03-05T22:56:32Z")

</div>

Hello,  
Regarding updating documents via Elasticsearch's bulk API, how are documents compared? As far as I know, for the "Create" action type the index will fail if index and type exists, and for the "Index" action type the index is deleted then reindexed. Are these documents compared by index name and ID, or is the entire document compared using a hash function or something similar? Is the same comparisons used for update/partial update APIs?  
If it is a hash function to compare documents, do the meta-fields factor in the equation?

Thanks!

---

<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:** [March 6, 2018, 1:16am UTC](https://discuss.elastic.co/t/update-document-questions/122609/2 "2018-03-06T01:16:55Z")

</div>

> how are documents compared?

By the `_id`.

---

<div class="post-metadata">

**Author:** ![Jonb32](https://avatars.discourse-cdn.com/v4/letter/j/c37758/32.png) [@Jonb32](https://discuss.elastic.co/u/Jonb32)\
**Post date:** [March 6, 2018, 2:07am UTC](https://discuss.elastic.co/t/update-document-questions/122609/3 "2018-03-06T02:07:57Z")

</div>

Hey David, simple enough 🙂. Looking over the code in [InternalEngine.java](https://github.com/elastic/elasticsearch/blob/0c2871c4d25cefe9a34d8fe6d967bc24687706c6/server/src/main/java/org/elasticsearch/index/engine/InternalEngine.java) in particular around the update functionality. It appears the only time we wouldn't call Lucene's updatedocument is if there is a version conflict between documents or if autogenerated IDs are used, correct? If I wanted to reduce the number of "deleted" documents in Lucene/avoid reindexing existing document which don't contain changes, does Elastic provide any functionality other than the force merge API?

---

<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:** [April 3, 2018, 2:08am UTC](https://discuss.elastic.co/t/update-document-questions/122609/4 "2018-04-03T02:08:31Z")

</div>

Closed on April 3, 2018, 2:08am UTC

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