How to specify Refresh.WaitFor with an IndexMany request?

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.

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

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)
);

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