1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- package main
- import (
- "fmt"
- util "jygit.jydev.jianyu360.cn/data_processing/common_utils"
- "jygit.jydev.jianyu360.cn/data_processing/common_utils/mongodb"
- "log"
- )
- func updateProject() {
- defer util.Catch()
- // 项目数据
- MgoP := &mongodb.MongodbSim{
- MongodbAddr: "172.17.4.85:27080",
- //MongodbAddr: "127.0.0.1:27080",
- Size: 10,
- DbName: "qfw",
- //Direct: true,
- }
- MgoP.InitPool()
- sess := MgoP.GetMgoConn()
- defer MgoP.DestoryMongoConn(sess)
- selected := map[string]interface{}{"projectname": 1, "tag_topinformation": 1, "pici": 1}
- it := sess.DB("qfw").C("projectset_20230904").Find(nil).Select(selected).Sort("pici").Iter()
- fmt.Println("updateProject 开始")
- count := 0
- for tmp := make(map[string]interface{}); it.Next(&tmp); count++ {
- if count%10000 == 0 {
- log.Println("current", count, tmp["projectname"])
- }
- if _, ok := tmp["tag_topinformation"]; ok {
- update := map[string]interface{}{
- "tag_topinformation": tmp["tag_topinformation"],
- }
- projectID := mongodb.BsonIdToSId(tmp["_id"])
- // 更新es
- updateEsPool <- []map[string]interface{}{
- {"_id": projectID},
- //{"_id": mongodb.BsonIdToSId(tmp["_id"])},
- update,
- }
- log.Println("aaaaaaaaaaaa", projectID, tmp["projectname"])
- //err := Es.UpdateDocument("projectset", projectID, update)
- //if err != nil {
- // log.Println(projectID, tmp["projectname"], "更新es 失败")
- //}
- }
- }
- log.Println("结束~~~~~~~~~~~~~")
- }
|