# DeleteByQuery with searchTemplate filter

**URL:** <https://discuss.elastic.co/t/deletebyquery-with-searchtemplate-filter/126257>\
**Category:** Elasticsearch\
**Created:** [March 30, 2018, 4:48pm UTC](https://discuss.elastic.co/t/deletebyquery-with-searchtemplate-filter/126257 "2018-03-30T16:48:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sudo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sudo/32/29414_2.png) [@sudo](https://discuss.elastic.co/u/sudo)\
**Post date:** [March 30, 2018, 4:48pm UTC](https://discuss.elastic.co/t/deletebyquery-with-searchtemplate-filter/126257/1 "2018-03-30T16:48:45Z")

</div>

Hi,

I am using es 5.2 and trying to use Java API for delete\_by\_query. I am using search template to build get queries which I would like to pass in

```
BulkIndexByScrollResponse response =
    DeleteByQueryAction.INSTANCE.newRequestBuilder(client)
        .filter(QueryBuilders.matchQuery("gender", "male")) 
        .source("persons")                                  
        .get(); 

```

I have seen several examples of matchQuery, boolQuery, matchAllQuery but I can't find anything on searchTemplateQueryBuilder.

Please let me know if I can actually use searchTemplate to build the query and pass it as filter for deletebyquery.

---

<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:** [April 27, 2018, 4:48pm UTC](https://discuss.elastic.co/t/deletebyquery-with-searchtemplate-filter/126257/2 "2018-04-27T16:48:45Z")

</div>

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