// BulkInsert insert multiple records with ID already set
BulkInsert insert multiple records with ID already set
// BulkInsert insert multiple records with ID already set
func (e *ElasticSearch) BulkInsert(rs []xlog.Record) (err error) {
	if len(rs) == 0 {
		return
	}
	bs := e.Client.Bulk()
	for _, r := range rs {
		r.ID = ""
		name := e.IndexName(r)
		r.Timestamp = r.Timestamp.Add(time.Hour * time.Duration(e.TimeOffset))
		bs = bs.Add(elastic.NewBulkIndexRequest().Index(name).Type("_doc").Doc(r))
	}
	_, err = bs.Do(context.Background())
	return
}
func ( e * ElasticSearch ) BulkInsert ( rs [ ] xlog . Record ) ( err error ) { if len ( rs ) == 0 { return } bs := e . Client . Bulk ( ) for _ , r := range rs { r . ID = " " name := e . IndexName ( r ) r . Timestamp = r . Timestamp . Add ( time . Hour * time . Duration ( e . TimeOffset ) ) bs = bs . Add ( elastic . NewBulkIndexRequest ( ) . Index ( name ) . Type ( " " ) . Doc ( r ) ) } _ , err = bs . Do ( context . Background ( ) ) return }
BulkInsert insert multiple records with ID already set
BulkInsert insert multiple records with ID already set
// clear the ID, let elasticsearch generate it // save index name // offset timestamp due to time zone // add a bulk operation, REMEMBER do not use pointer for Doc(r)