NEST - IndexMany with Version Type External?


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:

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.

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

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

Exactly what I was looking for, thanks so much!

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