olivere / elastic

Deprecated: Use the official Elasticsearch client for Go at https://github.com/elastic/go-elasticsearch
https://olivere.github.io/elastic/
MIT License
7.39k stars 1.15k forks source link

Bulk index failures #1657

Closed amirEBD closed 1 year ago

amirEBD commented 1 year ago

Which version of Elastic are you using?

elastic.v7 (for Elasticsearch 7.9)

Hi @olivere, I used the bulk index with bulk processor which are great together. I had an issue how to get which requests have trouble inserting/deleting? As ES mentions it'll return error on this occasions but how will olivere get my client aware of errors? Should it be on after function?

Another questoin I have is that wheter it's ok with the processor to concurrently Add(req) inside it? Is it best practice?

olivere commented 1 year ago

Bulk processor is OK if you don't have complex error handling (or even fire & forget). If you have a more complex logic, you should maybe change to do bulk indexing. Here's a recipe for that. Here's a test that uses an after function to handle errors.

Notice however that you should change your code to use the official Elasticsearch client for Go as this library is deprecated.