|
@@ -157,16 +157,16 @@ func (e *Elastic) Close() {
|
|
// }
|
|
// }
|
|
//}
|
|
//}
|
|
|
|
|
|
-func (e *Elastic) BulkSave(index, itype string, obj *[]map[string]interface{}, isDelBefore bool) {
|
|
|
|
|
|
+func (e *Elastic) BulkSave(index string, obj *[]map[string]interface{}, isDelBefore bool) {
|
|
client := e.GetEsConn()
|
|
client := e.GetEsConn()
|
|
defer e.DestoryEsConn(client)
|
|
defer e.DestoryEsConn(client)
|
|
if client != nil {
|
|
if client != nil {
|
|
req := client.Bulk()
|
|
req := client.Bulk()
|
|
for _, v := range *obj {
|
|
for _, v := range *obj {
|
|
if isDelBefore {
|
|
if isDelBefore {
|
|
- req = req.Add(es.NewBulkDeleteRequest().Index(index).Type(itype).Id(fmt.Sprintf("%v", v["_id"])))
|
|
|
|
|
|
+ req = req.Add(es.NewBulkDeleteRequest().Index(index).Id(fmt.Sprintf("%v", v["_id"])))
|
|
}
|
|
}
|
|
- req = req.Add(es.NewBulkIndexRequest().Index(index).Type(itype).Doc(v))
|
|
|
|
|
|
+ req = req.Add(es.NewBulkIndexRequest().Index(index).Id(fmt.Sprintf("%v", v["_id"])).Doc(v))
|
|
}
|
|
}
|
|
_, err := req.Do(context.Background())
|
|
_, err := req.Do(context.Background())
|
|
if err != nil {
|
|
if err != nil {
|