I have a list of "event" objects. Each event has its operation (delete, update, index, etc), its mapping type (document, folder, etc.), and the actual content to be indexed into Elasticsearch, if any. I don't know what any of these operations will be in advance. How can I use NEST to dynamically choose the bulk operation and mapping type for each of these events?
Asked
Active
Viewed 481 times
0
1 Answers
0
Bulk
method on ElasticClient
should fit your requirements.
You can pass various bulk operations into theBulkRequest
, this is a simple usage:
var bulkRequest = new BulkRequest();
bulkRequest.Operations = new List<IBulkOperation>
{
new BulkCreateDescriptor<Document>().Id(1).Document(new Document{}),
new BulkDeleteDescriptor<Document>().Id(2)
};
var bulkResponse = client.Bulk(bulkRequest);
Hope it helps.

Rob
- 9,664
- 3
- 41
- 43