# Is the cache updated when a document is updated?

**URL:** <https://discuss.elastic.co/t/is-the-cache-updated-when-a-document-is-updated/103967>\
**Category:** Elasticsearch\
**Created:** [October 14, 2017, 12:44am UTC](https://discuss.elastic.co/t/is-the-cache-updated-when-a-document-is-updated/103967 "2017-10-14T00:44:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dhavalk123](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dhavalk123/32/63294_2.png) [@dhavalk123](https://discuss.elastic.co/u/dhavalk123)\
**Post date:** [October 14, 2017, 12:44am UTC](https://discuss.elastic.co/t/is-the-cache-updated-when-a-document-is-updated/103967/1 "2017-10-14T00:44:53Z")

</div>

A single document update in ES is ACID but is the cache updated when the document is updated? I am doing filter queries and I think that even though I maybe able to update a document safely in a distributed environment, the cache would still show old value for sometime. So, is the cache eventually consistent?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [October 14, 2017, 2:58am UTC](https://discuss.elastic.co/t/is-the-cache-updated-when-a-document-is-updated/103967/2 "2017-10-14T02:58:18Z")

</div>

Caches are invalidated when a segment changes.  
If you update a doc you change the original segment, hence invalidating that cache, and then update the new segment which will then have a new cache created.

---

<div class="post-metadata">

**Author:** ![dhavalk123](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dhavalk123/32/63294_2.png) [@dhavalk123](https://discuss.elastic.co/u/dhavalk123)\
**Post date:** [October 14, 2017, 8:12am UTC](https://discuss.elastic.co/t/is-the-cache-updated-when-a-document-is-updated/103967/3 "2017-10-14T08:12:43Z")

</div>

Thank you so much for your reply. But would the new cache creation be eventually consistent? Can it happen that my filter query still gives old results for sometime?

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [October 14, 2017, 10:35am UTC](https://discuss.elastic.co/t/is-the-cache-updated-when-a-document-is-updated/103967/4 "2017-10-14T10:35:42Z")

</div>

Elasticsearch is not ACID. When you index or update a document it goes onto the transaction log. Periodically this is turned into segments, at which point the document is available for search.

---

<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 11, 2017, 10:35am UTC](https://discuss.elastic.co/t/is-the-cache-updated-when-a-document-is-updated/103967/5 "2017-11-11T10:35:45Z")

</div>

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