|
@@ -445,6 +445,31 @@ func Update(index, itype, id string, updateStr string) bool {
|
|
|
return b
|
|
|
}
|
|
|
|
|
|
+func BulkUpdate(index, itype string, ids []string, updateStr string) {
|
|
|
+ client := GetEsConn()
|
|
|
+ defer DestoryEsConn(client)
|
|
|
+ if client != nil {
|
|
|
+ defer func() {
|
|
|
+ if r := recover(); r != nil {
|
|
|
+ log.Println("[E]", r)
|
|
|
+ for skip := 1; ; skip++ {
|
|
|
+ _, file, line, ok := runtime.Caller(skip)
|
|
|
+ if !ok {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ go log.Printf("%v,%v\n", file, line)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }()
|
|
|
+ for _, id := range ids {
|
|
|
+ ret, err := client.Update().Index(index).Type(itype).Id(id).Script(updateStr).ScriptLang("groovy").Do()
|
|
|
+ if err != nil {
|
|
|
+ log.Println("更新检索出错:", err.Error())
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
//根据id删除索引对象
|
|
|
func DelById(index, itype, id string) bool {
|
|
|
client := GetEsConn()
|