# Detecting the end of a bulk indexing

**URL:** <https://discuss.elastic.co/t/detecting-the-end-of-a-bulk-indexing/52229>\
**Category:** Elasticsearch\
**Created:** [June 8, 2016, 3:19pm UTC](https://discuss.elastic.co/t/detecting-the-end-of-a-bulk-indexing/52229 "2016-06-08T15:19:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![paolociccarese](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paolociccarese/32/695_2.png) [@paolociccarese](https://discuss.elastic.co/u/paolociccarese)\
**Post date:** [June 8, 2016, 3:19pm UTC](https://discuss.elastic.co/t/detecting-the-end-of-a-bulk-indexing/52229/1 "2016-06-08T15:19:49Z")

</div>

How do I detect the end of a bulk indexing process? In other words, how do I know I am good to go knowing all data are available for search?

I've seen a few old messages on this topic but they seemed related to very specific use cases.

Thank you,  
Paolo

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [June 8, 2016, 3:39pm UTC](https://discuss.elastic.co/t/detecting-the-end-of-a-bulk-indexing/52229/2 "2016-06-08T15:39:42Z")

</div>

> [@paolociccarese](#):
>
> In other words, how do I know I am good to go knowing all data are available for search?

Short answer: just stick `?refresh` on the bulk request.

Long answer: It depends on your use case a bit. One way is to add `?refresh` on the bulk request if there is only a single bulk request. If you have a bunch of bulk requests then you can issue a refresh request after all of them. Both of these immediately make the data available - it'll be ready for search as soon as the response comes back.

The downside of explicit refreshes is that they create segments "right now". That means that they can create small segments. If you aren't adding other data to the index and you know you are done they is no downside to forcing a refresh - waiting for one wouldn't make anything better.

If you are adding data to the index at the same time as something you need to be visible then master has `?refresh=wait_for` that will let you, "wait for" the action to be made visible by some other refresh. Again, you don't need it if you are the only writer. It is for when you are writing and there will be other writes between yours and the scheduled refresh.

---

<div class="post-metadata">

**Author:** ![paolociccarese](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paolociccarese/32/695_2.png) [@paolociccarese](https://discuss.elastic.co/u/paolociccarese)\
**Post date:** [June 8, 2016, 4:17pm UTC](https://discuss.elastic.co/t/detecting-the-end-of-a-bulk-indexing/52229/3 "2016-06-08T16:17:26Z")

</div>

Thank you Nik, that is helpful.

And I assume when, for _?refresh=wait\_for_ you say "master" you mean it will be available in v.5 which would be consistent with this issue [https://github.com/elastic/elasticsearch/issues/1063](https://github.com/elastic/elasticsearch/issues/1063)

Correct?  
Thank you again,  
Paolo

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [June 8, 2016, 4:30pm UTC](https://discuss.elastic.co/t/detecting-the-end-of-a-bulk-indexing/52229/4 "2016-06-08T16:30:57Z")

</div>

> [@paolociccarese](#):
>
> it will be available in v.5

It didn't make 5.0.0-alpha-3 but it'll go into whatever release of 5.0.0 comes next.

---

<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 5, 2017, 10:45pm UTC](https://discuss.elastic.co/t/detecting-the-end-of-a-bulk-indexing/52229/5 "2017-07-05T22:45:16Z")

</div>


