I have a list of document IDs I want to delete.
The naive way works well:
foreach (var Id in IDs)
{
EC.Delete(Id);
}
but it is insanely slow.
So I tried this:
EC.DeleteMany(IDs);
which doesn't seem to do anything at all; it certainly doesn't delete the documents.
Then I tried the bulk approach:
var Bulk = new BulkDescriptor();
foreach (var R in RecordIDs)
{
Bulk.Index(_ => _.Document(new IndexedData { Id = R }));
}
And now this one fails:
"Invalid NEST response built from a unsuccessful low level call on POST: /_bulk\r\n# Audit trail of this API call:\r\n - BadResponse: Node: http://127.0.0.1:9200/ Took: 00:01:00.1360093\r\n - MaxTimeoutReached: Took: -736111.13:10:20.1704195\r\n# OriginalException: System.Net.WebException: The request was aborted: The request was canceled.\r\n at System.Net.ConnectStream.InternalWrite(Boolean async, Byte buffer, Int32 offset, Int32 size, AsyncCallback callback, Object state)\r\n at System.Net.ConnectStream.Write(Byte buffer, Int32 offset, Int32 size)\r\n at
...
So, the problem is a timeout, but this is on an idle development computer with elastic running on the same machine.
Could it be that bulk operation do no handle a large number of operation? (1.2million in this case).
Also, is there a better way to do this? creating an empty class for every command, just to put the ID in it seems incredibly wasteful when I could just pass the ID.