ivanqwam
(Ivan Monnier)
April 1, 2022, 7:22am
1
With much sweat I could build a Bulk Request, on the new Java API 8.1.0, like this
// build request
ArrayList<BulkOperation> bulkOperations = new ArrayList<BulkOperation>();
BulkOperation bulkOperation = BulkOperation.of(b -> b.index(i -> i.index(indexes).id(qesdocument.idValue()).document(jsonData)) );
bulkOperations.add(bulkOperation);
// run request
bulkResponse = client.bulk(b -> b.index(indexes).operations(bulkOperations));
// handle errors
if (bulkResponse.errors()) { .....
When issued on a bulk of hundreds of documents, not all of them made it to Elasticsearch.
There were errors , on some documents , somewhere ...
How can I handle fine grained errors to investigate what went wrong , just like what was provided in in the HLRC ?
dadoonet
(David Pilato)
April 1, 2022, 12:35pm
2
You have to iterate over the response hits.
You can do that with a stream and a filter to only collect the hits which have an error.
ivanqwam
(Ivan Monnier)
April 1, 2022, 1:27pm
3
Ok, did this, (old style programming)
if (bulkResponse.errors()) {
System.out.println("Erreur occured");
for (BulkResponseItem bulkResponseItem : bulkResponse.items()) {
if (bulkResponseItem.error() != null) {
System.out.println("Erreur id", bulkResponseItem.id());
System.out.println("Erreur seqNo", bulkResponseItem.seqNo());
System.out.println("Erreur result", bulkResponseItem.result());
System.out.println("Erreur type", bulkResponseItem.error().type());
System.out.println("Erreur reason", bulkResponseItem.error().reason());
System.out.println("Erreur caused by", bulkResponseItem.error().causedBy().reason());
System.out.println("Erreur String", bulkResponseItem.error().toString());
System.out.println("Erreur stackTrace", bulkResponseItem.error().stackTrace());
}
}
}
swallez
(Sylvain Wallez)
April 1, 2022, 4:10pm
4
@ivanqwam can you elaborate on that? What exactly are you referring to? This can be valuable information to improve the new client.
Thanks.
system
(system)
Closed
April 29, 2022, 4:10pm
5
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.