# Documents not deleted when using DeleteRequest within BulkProcessor

**URL:** https://discuss.elastic.co/t/documents-not-deleted-when-using-deleterequest-within-bulkprocessor/23480
**Category:** Elasticsearch
**Created:** [April 30, 2015, 12:03am UTC](https://discuss.elastic.co/t/documents-not-deleted-when-using-deleterequest-within-bulkprocessor/23480 "2015-04-30T00:03:51Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![dtuck9](https://avatars.discourse-cdn.com/v4/letter/d/54ee81/32.png) [@dtuck9](https://discuss.elastic.co/u/dtuck9)
#### Post date: [April 30, 2015, 12:03am UTC](https://discuss.elastic.co/t/documents-not-deleted-when-using-deleterequest-within-bulkprocessor/23480/1 "2015-04-30T00:03:51Z")

</div>

Trying to index/delete documents within one BulkProcessor object in the  
Java API. Indexing documents works great! Deleting, however, does not.

bulkProcessor.add(new DeleteRequest(index.getIndexingAlias(), index.getType(), entityId));

Nothing happens. Any ideas?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/e2774458-8542-4634-bd8d-1ccfd9837409%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e2774458-8542-4634-bd8d-1ccfd9837409%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [April 30, 2015, 4:53am UTC](https://discuss.elastic.co/t/documents-not-deleted-when-using-deleterequest-within-bulkprocessor/23480/2 "2015-04-30T04:53:19Z")

</div>

Do you try to delete a doc using an alias?  
Any failure or error reported by the bulk processor?

Hard to tell more without seeing the code / data.

David

> Le 30 avr. 2015 à 02:03, Diana Tuck [dtuck9@gmail.com](mailto:dtuck9@gmail.com) a écrit :
> 
> Trying to index/delete documents within one BulkProcessor object in the Java API. Indexing documents works great! Deleting, however, does not.
> 
> bulkProcessor.add(new DeleteRequest(index.getIndexingAlias(), index.getType(), entityId));
> 
> ## Nothing happens. Any ideas?
> 
> You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/e2774458-8542-4634-bd8d-1ccfd9837409%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e2774458-8542-4634-bd8d-1ccfd9837409%40googlegroups.com).  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/512A5411-A00C-4F02-B11E-A0B24A27E7E3%40pilato.fr](https://groups.google.com/d/msgid/elasticsearch/512A5411-A00C-4F02-B11E-A0B24A27E7E3%40pilato.fr).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![dtuck9](https://avatars.discourse-cdn.com/v4/letter/d/54ee81/32.png) [@dtuck9](https://discuss.elastic.co/u/dtuck9)
#### Post date: [April 30, 2015, 5:10pm UTC](https://discuss.elastic.co/t/documents-not-deleted-when-using-deleterequest-within-bulkprocessor/23480/3 "2015-04-30T17:10:00Z")

</div>

Thank you for the reply, David.

We are using an alias to delete. Is that a problem? Indexing with the  
alias through the bulk processor works fine.

There are no errors reported, it just seems to disappear into the oblivion.  
Here's our code for the BulkProcessor:

public static BulkProcessor getBulkProcessor(Client client, int esConcurrencyLevel, int esBulkSize, int esFlushInterval) {  
return BulkProcessor.builder(client, new BulkProcessor.Listener() {

```
    @Override
    public void beforeBulk(long executionId, BulkRequest bulkRequest) {
        LOG.debug("Processing {} requests in bulk process {}", bulkRequest.numberOfActions(), executionId);
    }

    @Override
    public void afterBulk(long executionId, BulkRequest bulkRequest, BulkResponse response) {

        if (response.hasFailures()) {
            for (BulkItemResponse item : response.getItems()) {
                LOG.error("Processing to index \"{}\" failed for entity id {} with message {}", item.getIndex(),
                        item.getId(), item.getFailureMessage());
            }
        }
    }

    @Override
    public void afterBulk(long executionId, BulkRequest bulkRequest, Throwable throwable) {
        LOG.error("Failed to process {} requests in bulk request {}: {}", bulkRequest.numberOfActions(),
                executionId, throwable.getMessage());
        throwable.printStackTrace();
    }
})
        .setBulkActions(esBulkSize)
        .setFlushInterval(TimeValue.timeValueSeconds(esFlushInterval))
        .setConcurrentRequests(esConcurrencyLevel)
        .build();

```

}

_Code for the delete request:_

bulkProcessor.add(new DeleteRequest(index.getIndexingAlias(), index.getType(), entityId));

where index.getIndexingAlias() is an alias (same alias used for indexing which is working), type is the document type "company" and entityId is the document ID.

What data would be helpful? An example document, the index metadata, something else?

On Wednesday, April 29, 2015 at 9:53:41 PM UTC-7, David Pilato wrote:

> Do you try to delete a doc using an alias?  
> Any failure or error reported by the bulk processor?
> 
> Hard to tell more without seeing the code / data.
> 
> David
> 
> Le 30 avr. 2015 à 02:03, Diana Tuck \<[dtu...@gmail.com](mailto:dtu...@gmail.com) \<javascript:\>\> a  
> écrit :
> 
> Trying to index/delete documents within one BulkProcessor object in the  
> Java API. Indexing documents works great! Deleting, however, does not.
> 
> bulkProcessor.add(new DeleteRequest(index.getIndexingAlias(), index.getType(), entityId));
> 
> Nothing happens. Any ideas?
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/e2774458-8542-4634-bd8d-1ccfd9837409%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e2774458-8542-4634-bd8d-1ccfd9837409%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/e2774458-8542-4634-bd8d-1ccfd9837409%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/e2774458-8542-4634-bd8d-1ccfd9837409%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/01b6ab18-78a8-44d0-b574-c649501ec21a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/01b6ab18-78a8-44d0-b574-c649501ec21a%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [May 1, 2015, 10:50pm UTC](https://discuss.elastic.co/t/documents-not-deleted-when-using-deleterequest-within-bulkprocessor/23480/4 "2015-05-01T22:50:57Z")

</div>

No as soon as you have only one index for this alias, indexing and deleting should work.

I don’t see anything suspicious here.

Any chance you could share on github your full code?

When you say that "nothing happens", do you mean that you never get the debug LOG « Processing {} … » ?  
Or do you mean that the document has not been removed ?

How do you test all that?

--  
David Pilato - Developer | Evangelist

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co/)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

@dadoonet [https://twitter.com/dadoonet](https://twitter.com/dadoonet) | @elasticsearchfr [https://twitter.com/elasticsearchfr](https://twitter.com/elasticsearchfr) | @scrutmydocs [https://twitter.com/scrutmydocs](https://twitter.com/scrutmydocs)

> Le 30 avr. 2015 à 19:10, Diana Tuck [dtuck9@gmail.com](mailto:dtuck9@gmail.com) a écrit :
> 
> Thank you for the reply, David.
> 
> We are using an alias to delete. Is that a problem? Indexing with the alias through the bulk processor works fine.
> 
> There are no errors reported, it just seems to disappear into the oblivion. Here's our code for the BulkProcessor:
> 
> public static BulkProcessor getBulkProcessor(Client client, int esConcurrencyLevel, int esBulkSize, int esFlushInterval) {  
> return BulkProcessor.builder(client, new BulkProcessor.Listener() {
> 
> ```
> @Override
> public void beforeBulk(long executionId, BulkRequest bulkRequest) {
> LOG.debug("Processing {} requests in bulk process {}", bulkRequest.numberOfActions(), executionId);
> }
> 
> @Override
> public void afterBulk(long executionId, BulkRequest bulkRequest, BulkResponse response) {
> 
> if (response.hasFailures()) {
> for (BulkItemResponse item : response.getItems()) {
> LOG.error("Processing to index \"{}\" failed for entity id {} with message {}", item.getIndex(),
> item.getId(), item.getFailureMessage());
> }
> }
> }
> 
> @Override
> public void afterBulk(long executionId, BulkRequest bulkRequest, Throwable throwable) {
> LOG.error("Failed to process {} requests in bulk request {}: {}", bulkRequest.numberOfActions(),
> executionId, throwable.getMessage());
> throwable.printStackTrace();
> }
> })
> .setBulkActions(esBulkSize)
> .setFlushInterval(TimeValue.timeValueSeconds(esFlushInterval))
> .setConcurrentRequests(esConcurrencyLevel)
> .build();
> 
> ```
> 
> }
> 
> Code for the delete request:
> 
> bulkProcessor.add(new DeleteRequest(index.getIndexingAlias(), index.getType(), entityId));
> 
> where index.getIndexingAlias() is an alias (same alias used for indexing which is working), type is the document type "company" and entityId is the document ID.
> 
> What data would be helpful? An example document, the index metadata, something else?
> 
> On Wednesday, April 29, 2015 at 9:53:41 PM UTC-7, David Pilato wrote:  
> Do you try to delete a doc using an alias?  
> Any failure or error reported by the bulk processor?
> 
> Hard to tell more without seeing the code / data.
> 
> David
> 
> Le 30 avr. 2015 à 02:03, Diana Tuck \<[dtu...@gmail.com](mailto:dtu...@gmail.com) \<javascript:\>\> a écrit :
> 
> > Trying to index/delete documents within one BulkProcessor object in the Java API. Indexing documents works great! Deleting, however, does not.
> > 
> > bulkProcessor.add(new DeleteRequest(index.getIndexingAlias(), index.getType(), entityId));
> > 
> > Nothing happens. Any ideas?
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/e2774458-8542-4634-bd8d-1ccfd9837409%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e2774458-8542-4634-bd8d-1ccfd9837409%40googlegroups.com) [https://groups.google.com/d/msgid/elasticsearch/e2774458-8542-4634-bd8d-1ccfd9837409%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/e2774458-8542-4634-bd8d-1ccfd9837409%40googlegroups.com?utm_medium=email&utm_source=footer).  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout) [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com) [mailto:elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/01b6ab18-78a8-44d0-b574-c649501ec21a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/01b6ab18-78a8-44d0-b574-c649501ec21a%40googlegroups.com) [https://groups.google.com/d/msgid/elasticsearch/01b6ab18-78a8-44d0-b574-c649501ec21a%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/01b6ab18-78a8-44d0-b574-c649501ec21a%40googlegroups.com?utm_medium=email&utm_source=footer).  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout) [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/C7602498-6322-4F06-86ED-01B5147FA1FE%40pilato.fr](https://groups.google.com/d/msgid/elasticsearch/C7602498-6322-4F06-86ED-01B5147FA1FE%40pilato.fr).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![shakunvohra](https://avatars.discourse-cdn.com/v4/letter/s/4af34b/32.png) [@shakunvohra](https://discuss.elastic.co/u/shakunvohra)
#### Post date: [March 31, 2017, 2:05am UTC](https://discuss.elastic.co/t/documents-not-deleted-when-using-deleterequest-within-bulkprocessor/23480/5 "2017-03-31T02:05:47Z")

</div>

Were you able to get this issue fixed? I'm having the same exact issue with BulkProcessor and delete and nothing is happening, no errors, no delete

---

<div class="post-metadata">

### Author: ![dtuck9](https://avatars.discourse-cdn.com/v4/letter/d/54ee81/32.png) [@dtuck9](https://discuss.elastic.co/u/dtuck9)
#### Post date: [March 31, 2017, 4:12am UTC](https://discuss.elastic.co/t/documents-not-deleted-when-using-deleterequest-within-bulkprocessor/23480/6 "2017-03-31T04:12:43Z")

</div>

Unfortunately I cannot remember what I ended up doing, and I no longer have access to the code to verify. I vaguely remember having to use the actual index name as opposed to the alias.

For our use case, however, deletions were relatively infrequent, so an acceptable approach was to just submit the DeleteRequest individually as they came in via a Kafka message.

Sorry I couldn't be of more help.

---

<div class="post-metadata">

### Author: ![shakunvohra](https://avatars.discourse-cdn.com/v4/letter/s/4af34b/32.png) [@shakunvohra](https://discuss.elastic.co/u/shakunvohra)
#### Post date: [May 3, 2017, 5:43pm UTC](https://discuss.elastic.co/t/documents-not-deleted-when-using-deleterequest-within-bulkprocessor/23480/7 "2017-05-03T17:43:52Z")

</div>

i had to do extra logging in "after bulk" and saw the errors 🙂

---

<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:00pm UTC](https://discuss.elastic.co/t/documents-not-deleted-when-using-deleterequest-within-bulkprocessor/23480/8 "2017-07-05T22:00:40Z")

</div>


