# How to get failed data from request when using BulkProcessor?

**URL:** <https://discuss.elastic.co/t/how-to-get-failed-data-from-request-when-using-bulkprocessor/132782>\
**Category:** Elasticsearch\
**Created:** [May 22, 2018, 10:37am UTC](https://discuss.elastic.co/t/how-to-get-failed-data-from-request-when-using-bulkprocessor/132782 "2018-05-22T10:37:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![2016Gary](https://avatars.discourse-cdn.com/v4/letter/2/51bf81/32.png) [@2016Gary](https://discuss.elastic.co/u/2016Gary)\
**Post date:** [May 22, 2018, 10:37am UTC](https://discuss.elastic.co/t/how-to-get-failed-data-from-request-when-using-bulkprocessor/132782/1 "2018-05-22T10:37:36Z")

</div>

Because of request failed，it will enter method (3) and it will lose some data. I want to save these failed data, but get null values. Why? And what should I do? Thx!

```
BulkProcessor bulkProcessor = BulkProcessor.builder(
client,  
new BulkProcessor.Listener() {
    @Override
    public void beforeBulk(long executionId,
                           BulkRequest request) { ... } (1)

    @Override
    public void afterBulk(long executionId,
                          BulkRequest request,
                          BulkResponse response) { ... } (2)

    @Override
    public void afterBulk(long executionId,
                          BulkRequest request,
                          Throwable failure) { (3)
          List<ActionRequest> list = request.requests();
          System.out.println(list); (4)
    } 
})
.setBulkActions(10000) 
.setBulkSize(new ByteSizeValue(5, ByteSizeUnit.MB)) 
.setFlushInterval(TimeValue.timeValueSeconds(5)) 
.setConcurrentRequests(1) 
.setBackoffPolicy(
    BackoffPolicy.exponentialBackoff(TimeValue.timeValueMillis(100), 3)) 
.build();

```

(4)result:

```
[null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null]
```

---

<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:** [June 19, 2018, 10:37am UTC](https://discuss.elastic.co/t/how-to-get-failed-data-from-request-when-using-bulkprocessor/132782/2 "2018-06-19T10:37:43Z")

</div>

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