# Need help to DeleteByQuery in NEST 2.1.1

**URL:** <https://discuss.elastic.co/t/need-help-to-deletebyquery-in-nest-2-1-1/47134>\
**Category:** Elasticsearch\
**Created:** [April 12, 2016, 3:06pm UTC](https://discuss.elastic.co/t/need-help-to-deletebyquery-in-nest-2-1-1/47134 "2016-04-12T15:06:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fabriziodb](https://avatars.discourse-cdn.com/v4/letter/f/7993a0/32.png) [@fabriziodb](https://discuss.elastic.co/u/fabriziodb)\
**Post date:** [April 12, 2016, 3:06pm UTC](https://discuss.elastic.co/t/need-help-to-deletebyquery-in-nest-2-1-1/47134/1 "2016-04-12T15:06:29Z")

</div>

i need to know if there is a way to delete all docs into one collection using nest 2.1.1,

this code:

```auto
elastic.DeleteByQuery<Doc>(del => del
    .Query(q => q
        .QueryString(qs=>qs.Query("*"))
    )
);

```

throw

> Error 6 No overload for method 'DeleteByQuery' takes 1 arguments D:\tfs\Produzione Documentale\MES\Utilities\TestIndiciFisco\TestIndiciFisco\Form1.cs 1509 12 TestIndiciFisco

elastic is ElasticClient  
Doc is the class mapping the index's documents.

thanks,

---

<div class="post-metadata">

**Author:** ![forloop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/forloop/32/9021_2.png) [@forloop](https://discuss.elastic.co/u/forloop)\
**Post date:** [April 13, 2016, 3:37am UTC](https://discuss.elastic.co/t/need-help-to-deletebyquery-in-nest-2-1-1/47134/2 "2016-04-13T03:37:17Z")

</div>

NEST 2.x contains the methods for [`DeleteByQuery`](https://github.com/elastic/elasticsearch-net/blob/2.x/src/Nest/Document/Multiple/DeleteByQuery/ElasticClient-DeleteByQuery.cs) but [the functionality has been removed from Elasticsearch in 2.x to a separate plugin that must be installed.](https://www.elastic.co/guide/en/elasticsearch/plugins/2.0/delete-by-query-plugin-reason.html)

If you install the plugin with

```auto
bin/plugin install delete-by-query

```

start your cluster and then change your call to

```auto
elastic.DeleteByQuery<Document>(
	"index", 
	typeof(Document), 
	d => d.Query(q => q.QueryString(qs=> qs.Query("*")))
);

```

It'll work as expected.

For deleting all documents in an index though, it'd be much quicker to just delete the index, and create a new one.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 10:59pm UTC](https://discuss.elastic.co/t/need-help-to-deletebyquery-in-nest-2-1-1/47134/3 "2017-07-05T22:59:46Z")

</div>


