diff options
Diffstat (limited to 'vendor/gopkg.in/olivere/elastic.v5/bulk.go')
-rw-r--r-- | vendor/gopkg.in/olivere/elastic.v5/bulk.go | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/vendor/gopkg.in/olivere/elastic.v5/bulk.go b/vendor/gopkg.in/olivere/elastic.v5/bulk.go index f2fa0ea73..f4228294f 100644 --- a/vendor/gopkg.in/olivere/elastic.v5/bulk.go +++ b/vendor/gopkg.in/olivere/elastic.v5/bulk.go @@ -11,7 +11,7 @@ import ( "fmt" "net/url" - "gopkg.in/olivere/elastic.v5/uritemplates" + "github.com/olivere/elastic/uritemplates" ) // BulkService allows for batching bulk requests and sending them to @@ -23,10 +23,11 @@ import ( // reuse BulkService to send many batches. You do not have to create a new // BulkService for each batch. // -// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/docs-bulk.html +// See https://www.elastic.co/guide/en/elasticsearch/reference/6.0/docs-bulk.html // for more details. type BulkService struct { - client *Client + client *Client + retrier Retrier index string typ string @@ -57,6 +58,13 @@ func (s *BulkService) reset() { s.sizeInBytesCursor = 0 } +// Retrier allows to set specific retry logic for this BulkService. +// If not specified, it will use the client's default retrier. +func (s *BulkService) Retrier(retrier Retrier) *BulkService { + s.retrier = retrier + return s +} + // Index specifies the index to use for all batches. You may also leave // this blank and specify the index in the individual bulk requests. func (s *BulkService) Index(index string) *BulkService { @@ -159,7 +167,8 @@ func (s *BulkService) NumberOfActions() int { } func (s *BulkService) bodyAsString() (string, error) { - var buf bytes.Buffer + // Pre-allocate to reduce allocs + buf := bytes.NewBuffer(make([]byte, 0, s.EstimatedSizeInBytes())) for _, req := range s.requests { source, err := req.Source() @@ -234,7 +243,14 @@ func (s *BulkService) Do(ctx context.Context) (*BulkResponse, error) { } // Get response - res, err := s.client.PerformRequestWithContentType(ctx, "POST", path, params, body, "application/x-ndjson") + res, err := s.client.PerformRequest(ctx, PerformRequestOptions{ + Method: "POST", + Path: path, + Params: params, + Body: body, + ContentType: "application/x-ndjson", + Retrier: s.retrier, + }) if err != nil { return nil, err } @@ -304,11 +320,14 @@ type BulkResponseItem struct { Type string `json:"_type,omitempty"` Id string `json:"_id,omitempty"` Version int64 `json:"_version,omitempty"` - Status int `json:"status,omitempty"` Result string `json:"result,omitempty"` + Shards *shardsInfo `json:"_shards,omitempty"` + SeqNo int64 `json:"_seq_no,omitempty"` + PrimaryTerm int64 `json:"_primary_term,omitempty"` + Status int `json:"status,omitempty"` ForcedRefresh bool `json:"forced_refresh,omitempty"` - Found bool `json:"found,omitempty"` Error *ErrorDetails `json:"error,omitempty"` + GetResult *GetResult `json:"get,omitempty"` } // Indexed returns all bulk request results of "index" actions. |