Skip to content

Commit

Permalink
Update elasticsearch client
Browse files Browse the repository at this point in the history
  • Loading branch information
eminano committed Jan 17, 2025
1 parent 06abe69 commit cb27bb2
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions internal/searchstore/elasticsearch/elasticsearch_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,13 +422,15 @@ func (ec *Client) SendBulkRequest(ctx context.Context, items []searchstore.BulkI
return nil, fmt.Errorf("perform: %w", err)
}
defer resp.Body.Close()

if resp.StatusCode > 299 {
return nil, fmt.Errorf("[SendBulkRequest] error response from Elasticsearch: %w", searchstore.ExtractResponseError(resp.Body, resp.StatusCode))
}

bodyBytes, err := io.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("read body: %w", err)
}
if resp.StatusCode > 299 {
return nil, fmt.Errorf("error from Elasticsearch: %d: %s", resp.StatusCode, bodyBytes)
}

return searchstore.VerifyResponse(bodyBytes, items)
}
Expand Down

0 comments on commit cb27bb2

Please sign in to comment.