# How to delete the data from elastic search using ElasticSearchAdmin in 5.6.x

**URL:** <https://discuss.elastic.co/t/how-to-delete-the-data-from-elastic-search-using-elasticsearchadmin-in-5-6-x/143153>\
**Category:** Elasticsearch\
**Created:** [August 6, 2018, 11:35am UTC](https://discuss.elastic.co/t/how-to-delete-the-data-from-elastic-search-using-elasticsearchadmin-in-5-6-x/143153 "2018-08-06T11:35:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kguru08](https://avatars.discourse-cdn.com/v4/letter/k/dc4da7/32.png) [@kguru08](https://discuss.elastic.co/u/kguru08)\
**Post date:** [August 6, 2018, 11:35am UTC](https://discuss.elastic.co/t/how-to-delete-the-data-from-elastic-search-using-elasticsearchadmin-in-5-6-x/143153/1 "2018-08-06T11:35:23Z")

</div>

I am trying to delete the data from ElasticSearch using "BulkByScrollResponse". If I pass the Elastic search client as admin I am Null pointer exception. Instead of ElasticSearhClient, I need to pass ElasticSearchAdmin.

**\_ With Elastic Search Client\_**

BulkByScrollResponse bResponse = DeleteByQueryAction.INSTANCE.newRequestBuilder(esc)  
.filter(QueryBuilders.boolQuery().must(QueryBuilders.termQuery("tenantId",tenantId))).source("audit").execute().get();  
bResponse.getDeleted();

**Result:** Null Pointer Exception

**\_ With Elastic search admin\_**  
BulkByScrollResponse bResponse = DeleteByQueryAction.INSTANCE.newRequestBuilder((ElasticsearchClient) esa.getClient())  
.filter(QueryBuilders.boolQuery().must(QueryBuilders.termQuery("tenantId",tenantId))).source("audit").execute().get();  
bResponse.getDeleted();

**Result:** Class Cast Exception

Please help to delete the data from Elastic Search.

---

<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:** [September 3, 2018, 11:35am UTC](https://discuss.elastic.co/t/how-to-delete-the-data-from-elastic-search-using-elasticsearchadmin-in-5-6-x/143153/2 "2018-09-03T11:35:26Z")

</div>

Closed on September 3, 2018, 11:35am UTC

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