(ctx context.Context, client *elasticsearch.TypedClient, index string, docs []B64Doc)
| 207 | } |
| 208 | |
| 209 | func 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 | } |