Bulk Update on ElasticSearch using NEST
You are passing the bulk request to the ElasticsearchClient
i.e. ElasticClient.Raw
, when you should be passing it to ElasticClient.BulkAsync()
or ElasticClient.Bulk()
which can accept a bulk request type.
Using BulkRequest
or BulkDescriptor
are two different approaches that are offered by NEST for writing queries; the former uses an Object Initializer Syntax for building up a request object while the latter is used within the Fluent API to build a request using lambda expressions.
In your example, BulkDescriptor
is used outside of the context of the fluent API, but both BulkRequest
and BulkDescriptor
implement IBulkRequest
so can be passed to ElasticClient.Bulk(IBulkRequest)
.
As for which to use, in this case it doesn't matter so whichever you prefer.