# How to specify Refresh.WaitFor with an IndexMany request?

**URL:** <https://discuss.elastic.co/t/how-to-specify-refresh-waitfor-with-an-indexmany-request/287934>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [October 28, 2021, 2:26pm UTC](https://discuss.elastic.co/t/how-to-specify-refresh-waitfor-with-an-indexmany-request/287934 "2021-10-28T14:26:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![astanton1978](https://avatars.discourse-cdn.com/v4/letter/a/e480ec/32.png) [@astanton1978](https://discuss.elastic.co/u/astanton1978)\
**Post date:** [October 28, 2021, 2:26pm UTC](https://discuss.elastic.co/t/how-to-specify-refresh-waitfor-with-an-indexmany-request/287934/1 "2021-10-28T14:26:13Z")

</div>

For the .net clients I dont see the option to wait for indexing to complete before returning the response when performing an IndexMany or IndexManyAsync. Its present for Index and IndexAsync.

Is there a way to specify this option when doing bulk inserts? Without it I have to write code that polls to see if all the millions of documents sent for bulk indexing were actually added.

---

<div class="post-metadata">

**Author:** ![forloop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/forloop/32/9021_2.png) [@forloop](https://discuss.elastic.co/u/forloop)\
**Post date:** [November 15, 2021, 8:43am UTC](https://discuss.elastic.co/t/how-to-specify-refresh-waitfor-with-an-indexmany-request/287934/2 "2021-11-15T08:43:30Z")

</div>

`IndexMany` and `IndexManyAsync` are simple convenience methods over the Bulk API, so don't expose all of the options available. To set `Refresh.WaitFor` would be

```auto
var client = new ElasticClient();

var docs = new [] 
{
	new { Name = "foo", Value = "bar" },
	new { Name = "foo2", Value = "bar2" },
	new { Name = "foo3", Value = "bar3" },
};

var bulkResponse = client.Bulk(b => b
	.Index("my-index")
	.Refresh(Refresh.WaitFor)
	.IndexMany(docs)
);

```

---

<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:** [December 13, 2021, 8:43am UTC](https://discuss.elastic.co/t/how-to-specify-refresh-waitfor-with-an-indexmany-request/287934/3 "2021-12-13T08:43:53Z")

</div>

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