bidding_test.go 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. package main
  2. import (
  3. util "jygit.jydev.jianyu360.cn/data_processing/common_utils"
  4. "jygit.jydev.jianyu360.cn/data_processing/common_utils/elastic"
  5. "jygit.jydev.jianyu360.cn/data_processing/common_utils/mongodb"
  6. "log"
  7. "strings"
  8. "testing"
  9. )
  10. // TestUpdateBiddingEs 更新bidding,site 乌鲁木齐地铁 错误标讯数据,删除es
  11. func TestUpdateBiddingEs(t *testing.T) {
  12. Mgo := &mongodb.MongodbSim{
  13. //MongodbAddr: "172.17.189.140:27080",
  14. MongodbAddr: "127.0.0.1:27083",
  15. Size: 10,
  16. DbName: "qfw",
  17. UserName: "SJZY_RWbid_ES",
  18. Password: "SJZY@B4i4D5e6S",
  19. Direct: true,
  20. }
  21. Mgo.InitPool()
  22. sess := Mgo.GetMgoConn()
  23. defer Mgo.DestoryMongoConn(sess)
  24. //es
  25. Es := &elastic.Elastic{
  26. S_esurl: "http://127.0.0.1:19805",
  27. //S_esurl: "http://172.17.4.184:19805",
  28. I_size: 5,
  29. Username: "es_all",
  30. Password: "TopJkO2E_d1x",
  31. }
  32. Es.InitElasticSize()
  33. //es 新集群
  34. //EsNew := &elastic.Elastic{
  35. // S_esurl: "http://127.0.0.1:19905",
  36. // //S_esurl: "http://172.17.4.184:19905",
  37. // I_size: 5,
  38. // Username: "jybid",
  39. // Password: "Top2023_JEB01i@31",
  40. //}
  41. //EsNew.InitElasticSize()
  42. where := map[string]interface{}{
  43. "site": "乌鲁木齐地铁",
  44. }
  45. query := sess.DB("qfw").C("bidding").Find(&where).Select(nil).Sort("-_id").Iter()
  46. count := 0
  47. for tmp := make(map[string]interface{}); query.Next(tmp); count++ {
  48. if count%100 == 0 {
  49. log.Println("current:", count)
  50. }
  51. if util.IntAll(tmp["extracttype"]) == -1 {
  52. continue
  53. }
  54. if util.IntAll(tmp["infoformat"]) != 1 {
  55. continue
  56. }
  57. id := mongodb.BsonIdToSId(tmp["_id"])
  58. title := util.ObjToString(tmp["title"])
  59. if strings.Contains(title, "工作人员捡到") || strings.Contains(title, "捡到") {
  60. log.Println(id)
  61. //update := map[string]interface{}{
  62. // "extracttype": -1,
  63. //}
  64. //Mgo.UpdateById("bidding", id, map[string]interface{}{"$set": update})
  65. //
  66. //err := Es.DeleteByID("bidding", id)
  67. //if err != nil {
  68. // log.Println("es delete err", err)
  69. //}
  70. //err = EsNew.DeleteByID("bidding", id)
  71. //if err != nil {
  72. // log.Println("esNew delete err", err)
  73. //}
  74. }
  75. }
  76. }