Andreas
Andreas

Reputation: 1776

How to do Bulk Delete in Elasticsearch C# Nest

First of all: I am very new to Elasticsearch and the Nest API in specific.

I found that wonderful answer from Russ Cam concerning bulk Insert of documents: NEST ElasticClient C# bulk insert collection

I have two Questions:

  1. How is the bulk Delete of documents done in such a way.
  2. Is it possible to explicitly specify the index name instead of inferring it from the document type?

Upvotes: 2

Views: 285

Answers (1)

Amish
Amish

Reputation: 36

Try a Delete by Query. This allows you to construct a query and delete all documents that match it. And yes, you can specify the indices used by passing a string, as in this example:

var response = _client.DeleteByQuery<MyClass>(q => q
            .Query(q => q
                // your query here
            )
            .Index("Index_Name_Here")
        );

Upvotes: 0

Related Questions