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