MCPcopy
hub / github.com/elastic/go-elasticsearch / ingestDocs

Function ingestDocs

_examples/bulk/base64.go:209–219  ·  view source on GitHub ↗
(ctx context.Context, client *elasticsearch.TypedClient, index string, docs []B64Doc)

Source from the content-addressed store, hash-verified

207}
208
209func ingestDocs(ctx context.Context, client *elasticsearch.TypedClient, index string, docs []B64Doc) (time.Duration, error) {
210 start := time.Now()
211 bulk := client.Bulk()
212 for _, doc := range docs {
213 if err := bulk.IndexOp(types.IndexOperation{Index_: &index}, doc); err != nil {
214 return 0, fmt.Errorf("add bulk operation: %w", err)
215 }
216 }
217 _, err := bulk.Do(ctx)
218 return time.Since(start), err
219}

Callers 1

mainFunction · 0.70

Calls 3

DoMethod · 0.65
BulkMethod · 0.45
IndexOpMethod · 0.45

Tested by

no test coverage detected