-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expose BulkResponseItem.status in BulkFailureException #2619
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
First, having two maps with the same key and different values would be an ungly solution in my opinion. This would need t be a map with a value that combines the reason with something. Second, where should this value come from? We get a private final Map<String, JsonData> metadata;
@Nullable
private final String type;
@Nullable
private final String reason;
@Nullable
private final String stackTrace;
@Nullable
private final ErrorCause causedBy;
private final List<ErrorCause> rootCause;
private final List<ErrorCause> suppressed; This is below the level of HTTP status codes. |
The value is taken from https://artifacts.elastic.co/javadoc/co/elastic/clients/elasticsearch-java/7.17.0/co/elastic/clients/elasticsearch/core/bulk/BulkResponseItem.html#status(). When it comes to how to put it - agree, it could be done as you said, but in that case the current getter would need to perform projection to keep the current API not broken. Unless it is ok to change the API of getFailedDocuments to return something like Map<String, FailureStatus>, where FailureStatus is basically pair of HTTP status and error message. |
Ok, I checked in the error itself. This is a breaking API change, therefore it could make it into 5.2, no backporting. And of course it needs to be documented in the release/migration docs. |
Hi,
I would like to propose a usability change in BulkFailureException class.
The class provides information on failed documents in form of Map {document._id->
BulkResponseItem.reason
}:The problem is that the
reason
is a string and it is problematic to reason about it when your client code needs to handle those failures in a specific way.For instance in my project I need to have special handling of conflicts (when an attempt was done to save a document with the same or lower version, HTTP status 409) and currently I have to rely on string message from native elasticsearch library (which could change in the future btw)
It would be great to have the integer
status
of a particular failure.Not to introduce a breaking change, I would imagine a new Map to be added as:
I could submit a PR if the above makes sense.
Thanks.
The text was updated successfully, but these errors were encountered: