# Does indices()-\>refresh() wait for the completion of Bulk API?

**URL:** https://discuss.elastic.co/t/does-indices-refresh-wait-for-the-completion-of-bulk-api/272914
**Category:** Elasticsearch
**Created:** [May 13, 2021, 1:32pm UTC](https://discuss.elastic.co/t/does-indices-refresh-wait-for-the-completion-of-bulk-api/272914 "2021-05-13T13:32:39Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Catalin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/catalin/32/65314_2.png) [@Catalin](https://discuss.elastic.co/u/Catalin)
#### Post date: [May 13, 2021, 1:32pm UTC](https://discuss.elastic.co/t/does-indices-refresh-wait-for-the-completion-of-bulk-api/272914/1 "2021-05-13T13:32:39Z")

</div>

In order to populate an index I have disabled its `refresh_interval` and I'm using the Bulk API for inserting.

The problem is I'm doing this in chunks of data and I need that after each chunk all the information is available for search.

```
data1: Bulk Insert
$client->indices()->refresh() // Elasticsearch-PHP API call
data2: Bulk Insert

```

Does the refresh operation wait for all the bulk operations to end ? If not, is there another way to achieve this ?

I know `?refresh=wait_for` with each bulk API call does this, but I feel it defies the use of the Bulk API.

---

<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: [May 17, 2021, 12:38am UTC](https://discuss.elastic.co/t/does-indices-refresh-wait-for-the-completion-of-bulk-api/272914/2 "2021-05-17T00:38:12Z")

</div>

> [@Catalin](#):
>
> I know `?refresh=wait_for` with each bulk API call does this, but I feel it defies the use of the Bulk API.

That'd be the best way given what you are doing here I think.

---

<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: [June 14, 2021, 12:38am UTC](https://discuss.elastic.co/t/does-indices-refresh-wait-for-the-completion-of-bulk-api/272914/3 "2021-06-14T00:38:33Z")

</div>

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