Jianghan 2 år sedan
förälder
incheckning
4da4106979
1 ändrade filer med 3 tillägg och 3 borttagningar
  1. 3 3
      elastic/elasticSim.go

+ 3 - 3
elastic/elasticSim.go

@@ -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()
 	defer e.DestoryEsConn(client)
 	if client != nil {
 		req := client.Bulk()
 		for _, v := range *obj {
 			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())
 		if err != nil {