# How to identify message causing error in bulk request

**URL:** <https://discuss.elastic.co/t/how-to-identify-message-causing-error-in-bulk-request/42885>\
**Category:** Elasticsearch\
**Created:** [February 26, 2016, 6:13pm UTC](https://discuss.elastic.co/t/how-to-identify-message-causing-error-in-bulk-request/42885 "2016-02-26T18:13:32Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![unknownunknown](https://avatars.discourse-cdn.com/v4/letter/u/4da419/32.png) [@unknownunknown](https://discuss.elastic.co/u/unknownunknown)\
**Post date:** [February 26, 2016, 6:54pm UTC](https://discuss.elastic.co/t/how-to-identify-message-causing-error-in-bulk-request/42885/5 "2016-02-26T18:54:14Z")

</div>

Thanks! I am hoping this will be very helpful, I got significantly more feedback this way. There were some minor Array vs. ArrayList-isms to get it to work for me, but otherwise not bad for pseudocode.

What ultimately worked for me:

```
                  @Override
                  public void afterBulk(long executionId, BulkRequest request, BulkResponse response) {
                            if (response.hasFailures()) {
                                    for (int i = 0; i < response.getItems().length; i++) {
                                        BulkItemResponse item = response.getItems()[i];
                                        if (item.isFailed()) {
                                              IndexRequest ireq = (IndexRequest) request.requests().get(i);
                                              logger.error("Failed while indexing to " + item.getIndex() + " type " + item.getType() + " " +
                                                           "request: [" + ireq + "]: [" + item.getFailureMessage() + "]");
                                        }
                                    }
                            }
                  }

```

I now get:

[elasticsearch[Dyna-Mite][transport\_client\_worker][T#5]{New I/O worker #70}] ERROR - Failed while indexing to data-2016.02.26 type datatype request: [index {[data-2016.02.26][datatype][null], source[{"json\_obj"}]: [MapperParsingException[failed to parse [\_source]]; nested: ElasticsearchParseException[Failed to parse content to map]; nested: JsonParseException[Unexpected character (':' (code 58)): was expecting either valid name character (for unquoted name) or double-quote (for quoted) to start field name#012 at [Source: [B@5f09799a; line: 1, column: 1779]]; ]

I am hopeful that this will be a great help in troubleshooting this problem, thanks.

---

_[View the full topic](https://discuss.elastic.co/t/how-to-identify-message-causing-error-in-bulk-request/42885)._
