|
@@ -157,16 +157,16 @@ func (e *Elastic) Close() {
|
|
// }
|
|
// }
|
|
//}
|
|
//}
|
|
|
|
|
|
-func (e *Elastic) BulkSave(index string, obj ...[]map[string]interface{}) {
|
|
|
|
|
|
+func (e *Elastic) BulkSave(index string, obj map[string]interface{}) {
|
|
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 k, v := range obj {
|
|
//if isDelBefore {
|
|
//if isDelBefore {
|
|
// req = req.Add(es.NewBulkDeleteRequest().Index(index).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).Id(fmt.Sprint(v[0])).Doc(v[1]))
|
|
|
|
|
|
+ req = req.Add(es.NewBulkIndexRequest().Index(index).Id(k).Doc(v))
|
|
}
|
|
}
|
|
_, err := req.Do(context.Background())
|
|
_, err := req.Do(context.Background())
|
|
if err != nil {
|
|
if err != nil {
|