es Bulk

github.com/olivere/elastic
bulk := client.Bulk()



// Elasticsearch _id counter starts at 0
docID := 0



// Iterate over the slice of Elasticsearch documents
for _, doc := range docs {



// Incrementally change the _id number in each iteration
docID++



// Convert the _id integer into a string
idStr := strconv.Itoa(docID)



// Create a new int64 float from time package for doc timestamp
doc.Timestamp = time.Now().Unix()
fmt.Println(“ntime.Now().Unix():”, doc.Timestamp)



// Declate a new NewBulkIndexRequest() instance
req := elastic.NewBulkIndexRequest()



// Assign custom values to the NewBulkIndexRequest() based on the Elasticsearch
// index and the request type
req.OpType(“index”) // set type to “index” document
req.Index(indexName)
//req.Type(“_doc”) // Doc types are deprecated (default now _doc)
req.Id(idStr)
req.Doc(doc)



// Print information about the NewBulkIndexRequest object
fmt.Println(“req:”, req)
fmt.Println(“req TYPE:”, reflect.TypeOf(req))



// Add the new NewBulkIndexRequest() to the client.Bulk() instance
bulk = bulk.Add(req)
fmt.Println(“NewBulkIndexRequest().NumberOfActions():”, bulk.NumberOfActions())
}



// Do() sends the bulk requests to Elasticsearch
bulkResp, err := bulk.Do(ctx)




https://kb.objectrocket.com/elasticsearch/how-to-bulk-index-elasticsearch-documents-using-golang-450


Category storage