I notice that I can use BulkIndexer if I want to send data into elasticsearch in bulk. As stated in the Elastigo documentation
A bulk indexer creates goroutines, and channels for connecting and sending data to elasticsearch in bulk, using buffers.
Code in elastigo to insert in bulk
var c_es = elastigo.NewConn()
var indexer = c_es.NewBulkIndexer(50)
func insertInBulkElastic(){
//Create a custom error function when inserting data into elasticsearch
//in bulk
indexer.Sender = func(buf *bytes.Buffer) error {
// @buf is the buffer of docs about to be written
respJson, err := c_es.DoCommand("POST", "/_bulk", nil, buf)
if err != nil {
// handle it better than this
fmt.Println("Error", string(respJson)) //
fmt.Println("Error", err)
}
if err == nil {
fmt.Println("The data was inserted successfullly to elastic search")
}
return err
}
}
Does anyone know how to send bulk request using olivere for golang?
Thanks