# Is it possible to use DeleteByQueryRequest with RestHighLevelClient?

**URL:** <https://discuss.elastic.co/t/is-it-possible-to-use-deletebyqueryrequest-with-resthighlevelclient/126201>\
**Category:** Elasticsearch\
**Created:** [March 30, 2018, 7:56am UTC](https://discuss.elastic.co/t/is-it-possible-to-use-deletebyqueryrequest-with-resthighlevelclient/126201 "2018-03-30T07:56:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![agazzarini](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/agazzarini/32/16976_2.png) [@agazzarini](https://discuss.elastic.co/u/agazzarini)\
**Post date:** [March 30, 2018, 7:56am UTC](https://discuss.elastic.co/t/is-it-possible-to-use-deletebyqueryrequest-with-resthighlevelclient/126201/1 "2018-03-30T07:56:05Z")

</div>

I'm not able to find some example and I even didn't get the point if such thing is possible or I should switch to low level client (and in this case I'm wondering what the role of org.elasticsearch.index.reindex.DeleteByQueryRequest is) .

I'm using ES 6.2.3

Thanks in advance  
Andrea

---

<div class="post-metadata">

**Author:** ![javanna](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javanna/32/4698_2.png) [@javanna](https://discuss.elastic.co/u/javanna)\
**Post date:** [April 6, 2018, 1:20pm UTC](https://discuss.elastic.co/t/is-it-possible-to-use-deletebyqueryrequest-with-resthighlevelclient/126201/2 "2018-04-06T13:20:06Z")

</div>

Hi Andrea,  
delete by query is not supported yet by the high-level REST client. You can see which API are supported in our docs: [https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-high-supported-apis.html](https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-high-supported-apis.html) .

If you use the low-level REST client instead, I don't think that DeleteByQueryRequest will help. You need to provide the request body as a string or byte array as part of an HttpEntity (that's what the apache http client calls it). Maybe for the query part you can reuse the SearchRequest or SearchSourceBuilder and print out its state using the toXContent method though.

Cheers  
Luca

---

<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:** [May 4, 2018, 1:20pm UTC](https://discuss.elastic.co/t/is-it-possible-to-use-deletebyqueryrequest-with-resthighlevelclient/126201/3 "2018-05-04T13:20:06Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
