Delete all from a type using ElasticSearch.net

Having troubles deleting an entire type from elasticsearch.net

public void DeleteIndexedItemsbyType(string indexType)
{
ConnectionConfiguration config = new ConnectionConfiguration(new Uri(this.uri));
ConnectionConfiguration exposed = config.ExposeRawResponse(true);
ElasticsearchClient client = new ElasticsearchClient(config, null, null, null);

           //Here's where I go wrong not sure what to put into the delete since i don't want a specific ID
            var bulk = new object[]
            {
               { "delete" : { "_index" : "test", "_type" : "type1", "_id" : "2" } }
            }
            client.Bulk(bulk);

}

In Sense I would do this:

DELETE indexname/typename

How do I do the equivalent with ElasticSearch.net?

Hi Garett,

Hope you'd have found the solution by now. Can you please share me the sample code on how to delete all or delete a document matching given condition using Elasticsearch.net API.

Regards,
Sreeram

As of version 2.0 you can no longer delete an entire type easily. You can delete by query with delete by query plugin.

For just deleting a single ID I did it like this.

ElasticSearchClient.Delete(elasticSearchIndex, entityName.ToLower(), idValue, null);

Thanks a lot for your response :slight_smile: