123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- package main
- import (
- util "jygit.jydev.jianyu360.cn/data_processing/common_utils"
- "jygit.jydev.jianyu360.cn/data_processing/common_utils/elastic"
- "jygit.jydev.jianyu360.cn/data_processing/common_utils/mongodb"
- "log"
- "strings"
- "testing"
- )
- // TestUpdateBiddingEs 更新bidding,site 乌鲁木齐地铁 错误标讯数据,删除es
- func TestUpdateBiddingEs(t *testing.T) {
- Mgo := &mongodb.MongodbSim{
- //MongodbAddr: "172.17.189.140:27080",
- MongodbAddr: "127.0.0.1:27083",
- Size: 10,
- DbName: "qfw",
- UserName: "SJZY_RWbid_ES",
- Password: "SJZY@B4i4D5e6S",
- Direct: true,
- }
- Mgo.InitPool()
- sess := Mgo.GetMgoConn()
- defer Mgo.DestoryMongoConn(sess)
- //es
- Es := &elastic.Elastic{
- S_esurl: "http://127.0.0.1:19805",
- //S_esurl: "http://172.17.4.184:19805",
- I_size: 5,
- Username: "es_all",
- Password: "TopJkO2E_d1x",
- }
- Es.InitElasticSize()
- //es 新集群
- //EsNew := &elastic.Elastic{
- // S_esurl: "http://127.0.0.1:19905",
- // //S_esurl: "http://172.17.4.184:19905",
- // I_size: 5,
- // Username: "jybid",
- // Password: "Top2023_JEB01i@31",
- //}
- //EsNew.InitElasticSize()
- where := map[string]interface{}{
- "site": "乌鲁木齐地铁",
- }
- query := sess.DB("qfw").C("bidding").Find(&where).Select(nil).Sort("-_id").Iter()
- count := 0
- for tmp := make(map[string]interface{}); query.Next(tmp); count++ {
- if count%100 == 0 {
- log.Println("current:", count)
- }
- if util.IntAll(tmp["extracttype"]) == -1 {
- continue
- }
- if util.IntAll(tmp["infoformat"]) != 1 {
- continue
- }
- id := mongodb.BsonIdToSId(tmp["_id"])
- title := util.ObjToString(tmp["title"])
- if strings.Contains(title, "工作人员捡到") || strings.Contains(title, "捡到") {
- log.Println(id)
- //update := map[string]interface{}{
- // "extracttype": -1,
- //}
- //Mgo.UpdateById("bidding", id, map[string]interface{}{"$set": update})
- //
- //err := Es.DeleteByID("bidding", id)
- //if err != nil {
- // log.Println("es delete err", err)
- //}
- //err = EsNew.DeleteByID("bidding", id)
- //if err != nil {
- // log.Println("esNew delete err", err)
- //}
- }
- }
- }
|