# NEST - IndexMany with Version Type External?

**URL:** <https://discuss.elastic.co/t/nest-indexmany-with-version-type-external/226381>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [April 3, 2020, 10:04am UTC](https://discuss.elastic.co/t/nest-indexmany-with-version-type-external/226381 "2020-04-03T10:04:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pikabanga](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pikabanga/32/65614_2.png) [@Pikabanga](https://discuss.elastic.co/u/Pikabanga)\
**Post date:** [April 3, 2020, 10:04am UTC](https://discuss.elastic.co/t/nest-indexmany-with-version-type-external/226381/1 "2020-04-03T10:04:28Z")

</div>

Hi!

I am looking for a way to use the External Version Type when using NEST's "IndexMany" API, but I can't find it.

When doing a simple index single it works just fine:

```cs
public Task IndexDocumentAsync<T>(T document, long? version, CancellationToken cancellationToken = default) where T : class
            => _client.IndexAsync(document, d => d.VersionType(VersionType.External).Version(version), cancellationToken);

```

Is there no equivalent for IndexMany?

I'm using version 6.8.4 of NEST.

---

<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:** [April 7, 2020, 5:30am UTC](https://discuss.elastic.co/t/nest-indexmany-with-version-type-external/226381/2 "2020-04-07T05:30:25Z")

</div>

`IndexMany` is a convenience simple helper method over the full capabilities of the `Bulk` method. To use `VersionType` and `Version` when indexing many documents, you can do

```auto
var client = new ElasticClient();
var documents = new []
{
	new Document { Name = "foo" },
	new Document { Name = "bar" },
	new Document { Name = "baz" }
};

var version = 2;

var bulkResponse = client.Bulk(b => b
	.IndexMany(documents, (descriptor, doc) => descriptor
		.VersionType(VersionType.External)
		.Version(version)
	)
);

```

---

<div class="post-metadata">

**Author:** ![Pikabanga](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pikabanga/32/65614_2.png) [@Pikabanga](https://discuss.elastic.co/u/Pikabanga)\
**Post date:** [April 8, 2020, 5:28pm UTC](https://discuss.elastic.co/t/nest-indexmany-with-version-type-external/226381/3 "2020-04-08T17:28:02Z")

</div>

Exactly what I was looking for, thanks so much!

---

<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:** [May 6, 2020, 5:28pm UTC](https://discuss.elastic.co/t/nest-indexmany-with-version-type-external/226381/4 "2020-05-06T17:28:06Z")

</div>

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