# How to wait for changes to be comitted?

**URL:** <https://discuss.elastic.co/t/how-to-wait-for-changes-to-be-comitted/22287>\
**Category:** Elasticsearch\
**Created:** [February 20, 2015, 8:09am UTC](https://discuss.elastic.co/t/how-to-wait-for-changes-to-be-comitted/22287 "2015-02-20T08:09:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abid\_Hussain](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@Abid\_Hussain](https://discuss.elastic.co/u/Abid_Hussain)\
**Post date:** [February 20, 2015, 8:09am UTC](https://discuss.elastic.co/t/how-to-wait-for-changes-to-be-comitted/22287/1 "2015-02-20T08:09:01Z")

</div>

Hi all,

In one of our integration test we do the following:

1. create an index
2. put some docs in the created index
3. assert that documents exist in index

Step 3 sometimes fails if we don't put a Thread.sleep(1000) between 2 and 3.

After reading the docs, I think performing a FlushRequest might help:  
client.admin().indices().flush(new FlushRequest(indexName)).actionGet();

My question is: are all changes commited when receiving the response of the  
flush request or is flush request performed in an asynchrounus manner?

Regards,

Abid

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/4dcb667c-2ab5-4457-85ff-70327e520c43%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/4dcb667c-2ab5-4457-85ff-70327e520c43%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [February 20, 2015, 8:26am UTC](https://discuss.elastic.co/t/how-to-wait-for-changes-to-be-comitted/22287/2 "2015-02-20T08:26:03Z")

</div>

You have to use "setRefresh(true)" in the index action to be able to search  
documents in the index immediately. Note, ES does not "commit" anything. It  
re-opens an index reader which is in expensive operation, do the default  
setting is one second for auto refresh.

"Flush" does not make sense in that context at all, it just clears the  
translog and all pending index requests to make sure they are passed to  
Lucene.

Jörg

On Fri, Feb 20, 2015 at 9:09 AM, Abid Hussain [hussain@novacom.mygbiz.com](mailto:hussain@novacom.mygbiz.com)  
wrote:

> Hi all,
> 
> In one of our integration test we do the following:
> 
> 1. create an index
> 2. put some docs in the created index
> 3. assert that documents exist in index
> 
> Step 3 sometimes fails if we don't put a Thread.sleep(1000) between 2 and  
> 3.
> 
> After reading the docs, I think performing a FlushRequest might help:  
> client.admin().indices().flush(new FlushRequest(indexName)).actionGet();
> 
> My question is: are all changes commited when receiving the response of  
> the flush request or is flush request performed in an asynchrounus manner?
> 
> Regards,
> 
> Abid
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/4dcb667c-2ab5-4457-85ff-70327e520c43%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/4dcb667c-2ab5-4457-85ff-70327e520c43%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/4dcb667c-2ab5-4457-85ff-70327e520c43%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/4dcb667c-2ab5-4457-85ff-70327e520c43%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoFUd6BUam1VpvGMetJUM1-ui9jR%3D%3D1b6c11rLgmfX\_ayQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoFUd6BUam1VpvGMetJUM1-ui9jR%3D%3D1b6c11rLgmfX_ayQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:31am UTC](https://discuss.elastic.co/t/how-to-wait-for-changes-to-be-comitted/22287/3 "2017-07-06T00:31:17Z")

</div>


