From 7c051c5e9e286fe5ba42df2ac3e87595911b52cf Mon Sep 17 00:00:00 2001 From: Kellen Miller Date: Wed, 2 Oct 2024 12:39:24 -0400 Subject: [PATCH] execute item failure callback execution on bulk request error --- opensearchutil/bulk_indexer.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/opensearchutil/bulk_indexer.go b/opensearchutil/bulk_indexer.go index e2296ba5..816098bf 100644 --- a/opensearchutil/bulk_indexer.go +++ b/opensearchutil/bulk_indexer.go @@ -503,9 +503,7 @@ func (w *worker) flush(ctx context.Context) error { blk, err = w.bi.config.Client.Bulk(ctx, req) if err != nil { - if err != nil { - return w.handleBulkError(ctx, fmt.Errorf("flush: %w", err)) - } + return w.handleBulkError(ctx, fmt.Errorf("flush: %w", err)) } for i, blkItem := range blk.Items { @@ -518,7 +516,7 @@ func (w *worker) flush(ctx context.Context) error { item = w.items[i] // The OpenSearch bulk response contains an array of maps like this: // [ { "index": { ... } }, { "create": { ... } }, ... ] - // We range over the map, to set the first key and value as "op" and "info". + // We range over the map, to set the last key and value as "op" and "info". for k, v := range blkItem { op = k info = v