Skip to content

Extend BulkFailureException.failedDocuments return type to show more details about failure #2633

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

Merged
merged 1 commit into from
Jul 18, 2023

Conversation

ilya-ulyanov
Copy link
Contributor

Whenever a bulk operation (insert or update) fails, there maybe a need to handle a failure of every document in a specific way based on a reason of failure.

Relying on a String error message coming from native Elasticsearch library (the current implementation) is not reliable, as requires checking for a specific sub-string, and the message itself may change in the future.

This PR proposes a change, which will expose an HTTP response code (taken from https://artifacts.elastic.co/javadoc/co/elastic/clients/elasticsearch-java/7.17.0/co/elastic/clients/elasticsearch/core/bulk/BulkResponseItem.html#status()) in addition to currently exposed error message, so that it will be much more convenient to handle specific failure reasons (e.g. 409 - conflict, when trying to save a document with version less than or equal to the currently stored in Elasticsearch).

  • You have read the Spring Data contribution guidelines.
  • There is a ticket in the bug tracker for the project in our issue tracker. Add the issue number to the Closes #issue-number line below
  • You use the code formatters provided here and have them applied to your changes. Don’t submit any formatting related changes.
  • You submit test cases (unit or integration tests) that back your changes.
  • You added yourself as author in the headers of the classes you touched. Amend the date range in the Apache license header if needed. For new types, add the license header (copy from another file and set the current year only).

Closes #2619

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jul 15, 2023
@sothawo sothawo added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Jul 18, 2023
@sothawo sothawo merged commit c7000fc into spring-projects:main Jul 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose BulkResponseItem.status in BulkFailureException
3 participants