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);
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
.VersionType(VersionType.External)
.Version(version)
)
);
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.