# Elasticsearch returning inconsistent data

**URL:** <https://discuss.elastic.co/t/elasticsearch-returning-inconsistent-data/210442>\
**Category:** Elasticsearch\
**Created:** [December 4, 2019, 1:02am UTC](https://discuss.elastic.co/t/elasticsearch-returning-inconsistent-data/210442 "2019-12-04T01:02:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Veshnu\_Ramakrishnan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/veshnu_ramakrishnan/32/53329_2.png) [@Veshnu\_Ramakrishnan](https://discuss.elastic.co/u/Veshnu_Ramakrishnan)\
**Post date:** [December 4, 2019, 1:02am UTC](https://discuss.elastic.co/t/elasticsearch-returning-inconsistent-data/210442/1 "2019-12-04T01:02:24Z")

</div>

I have an index which stores user information. On one side I am updating the index with changes. The other side I am search user with display name. I have a problem now.  
Say { "name": "gOz7nH2Sk3242342"}. Then i change it to { "name": "gOz7nH2Sk8ethXV4"}. I started a client which in a loop searches for the prefix "gOz7nH".  
My response goes.  
{ "name": "gOz7nH2Sk3242342"}  
{ "name": "gOz7nH2Sk8ethXV4"}  
{ "name": "gOz7nH2Sk3242342"}  
{ "name": "gOz7nH2Sk8ethXV4"}  
{ "name": "gOz7nH2Sk8ethXV4"}

I don't understand. For a moment I get the old data and then it returns the new data. Where is this inconsistency coming from?

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [December 4, 2019, 1:04pm UTC](https://discuss.elastic.co/t/elasticsearch-returning-inconsistent-data/210442/2 "2019-12-04T13:04:00Z")

</div>

By default Elasticsearch takes up to one second to make indexed data available for search. However this is a setting applied to each shard. So if you are hitting shard0 first,. which had already done that refresh, but the second search hits a copy of that shard which has not, you may encounter this situation. You could try to alleviate this with the `refresh=wait_for` setting when indexing data.

--Alex

---

<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:** [January 1, 2020, 5:55pm UTC](https://discuss.elastic.co/t/elasticsearch-returning-inconsistent-data/210442/4 "2020-01-01T17:55:34Z")

</div>

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