elasticsearch-net icon indicating copy to clipboard operation
elasticsearch-net copied to clipboard

Bulk delete API is not respecting the index in the current request

Open bonny-bonev opened this issue 6 months ago • 0 comments

Elastic.Clients.Elasticsearch version: 8.11

Elasticsearch version:8.11

.NET runtime version:4.8

Operating system version:Win 11

Description of the problem including expected versus actual behavior: When using the bulk API for delete, the index is not respected. Example: var request = new BulkRequest(indexName) { Refresh = Refresh.True }; foreach (var document in documents) { request.Operations.Add(new BulkDeleteOperation<SearchModel.Document>(document.IdentityField.Value.ToString())); } this.elasticClient.Bulk(request); // Results in error that there is no default index. The "indexName" is not used for some reason. this.elasticClient.Bulk(b => b.Index(indexName).DeleteMany(documents)); // Same error. Even tough I am setting the "indexName", it is not respected.

For context, this works as expected for single document: this.elasticClient.Delete(new DeleteRequest(indexName, documents.First().IdentityField.Value.ToString()));

Steps to reproduce:

  1. Create Elasticsearch client with valid connection
  2. Call the bulk delete API

Expected behavior The documents are deleted from the passed index and no error is thrown

Provide ConnectionSettings (if relevant):

Provide DebugInformation (if relevant):

bonny-bonev avatar Dec 12 '23 08:12 bonny-bonev