Skip to content
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

Is there a way to get bulk request failed items via save all or in the exception object #70

Open
gauravbrills opened this issue Jul 22, 2018 · 3 comments
Assignees
Labels

Comments

@gauravbrills
Copy link
Contributor

Hi , I am using spring data jest to index some of my bulk data sets using spring data saveAll method . THis breaks sometimes and throws an exception as below
om.github.vanroy.springdata.jest.exception.JestElasticsearchException: Cannot execute jest action , response code : 200 , error : One or more of the items in the Bulk request failed, check BulkResult.getItems() for more information. , message : null at com.github.vanroy.springdata.jest.mapper.DefaultErrorMapper.mapError(DefaultErrorMapper.java:30) at com.github.vanroy.springdata.jest.JestElasticsearchTemplate.execute(JestElasticsearchTemplate.java:1218) at com.github.vanroy.springdata.jest.JestElasticsearchTemplate.execute(JestElasticsearchTemplate.java:1208) at com.github.vanroy.springdata.jest.JestElasticsearchTemplate.bulkIndex(JestElasticsearchTemplate.java:697) at org.springframework.data.elasticsearch.repository.support.AbstractElasticsearchRepository.saveAll(AbstractElasticsearchRepository.java:184)

This is fine but could there be a way to get the bulk result object in the exception throws so the calling client can be aware of how to handle and debug the same .

@VanRoy
Copy link
Owner

VanRoy commented Aug 2, 2018

Hi @gauravbrills ,

You can catch JestElasticsearchException and use getResult to retrieve result data.

Exemple :

try {
    result = elasticsearchTemplate. bulkIndex(XXX)
} catch(JestElasticsearchException e) {
    ((BulkResult) e.getResult()).getItems()
}

Please keep me in touch if it works for you.

@VanRoy VanRoy added the question label Aug 2, 2018
@VanRoy VanRoy self-assigned this Aug 2, 2018
@gauravbrills
Copy link
Contributor Author

@VanRoy Ya I am aware of the above approach and doing by using the same in my custom repository . but could we ha some custom method to do this some kind of abstraction in a a jest specific repository . Though I agree the design of jest is to follow core spring data elasticsearch interfaces .

Though not a major issue ..

@VanRoy
Copy link
Owner

VanRoy commented Aug 6, 2018

@gauravbrills Indeed, I try to stay close as possible to SDE. But your idea could be interested, I will think about it.

Thanks for your feedback.
Julien.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants