Hi there,
I have working code to index documents using BulkProcessor. I need to ensure a kind of correctness of bulk indexing - I need to report failed documents. I can access response items in afterBulk callback (if there were some failed documents) or request items in afterBulk callback (if there was a whole bulk execution failure), however I can access only few properties (or geters) of request/response items. I can access id, index, type etc.
I have got situation where id field is not enough information to classify failed document.
Is there a way to add custom property to request, which will be accessible within response ?
Here is snippet what i want to achieve:
BulkProcessor bulkProcessor = BulkProcessor.builder(elasticsearchClient, new BulkProcessor.Listener() {
@Override
public void beforeBulk(long executionId, BulkRequest request) {
}
@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];
// bulk failed item
if(item.isFailed())
{
//item.getId(), item.index(), item.getFailureMessage() ...
String something = item.getSomething(); // <- this is what i want to achieve
}
}
}
}
@Override
public void afterBulk(long executionId, BulkRequest request, Throwable failure) {
// whole bulk failed, no request was indexed
for (int i = 0; i < request.requests().size(); i++)
{
//item.getId(), item.index() ...
String something = request.requests().get(i).getSomething(); // <- this is what i want to achieve
}
}
})
. ... settings
.build();
Is it even possible ? Elasticsearch Java Client is pretty complex to me, so I need help. Stack Overflow is maybe better place to ask, but I was very satisfied with my previous experience with this forum.
Thank you