|
@@ -8,10 +8,8 @@ import (
|
|
|
"go.mongodb.org/mongo-driver/bson"
|
|
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
|
|
"go.mongodb.org/mongo-driver/mongo/options"
|
|
|
- "gopkg.in/olivere/elastic.v1"
|
|
|
"log"
|
|
|
"net"
|
|
|
- "net/http"
|
|
|
"regexp"
|
|
|
"strings"
|
|
|
"sync"
|
|
@@ -336,121 +334,15 @@ func dealWithEsData(name string, tmpid string) {
|
|
|
|
|
|
}
|
|
|
|
|
|
-func TemporaryTest() {
|
|
|
- log.Println("测试......导出数据")
|
|
|
|
|
|
|
|
|
- QfwMgo85 = &MongodbSim{
|
|
|
- MongodbAddr: "172.17.4.187:27082,172.17.145.163:27083",
|
|
|
- Size: 5,
|
|
|
- DbName: "mixdata",
|
|
|
- UserName: "fengweiqiang",
|
|
|
- PassWord: "fwq@123123",
|
|
|
- }
|
|
|
- QfwMgo85.InitPool()
|
|
|
-
|
|
|
- Client_Es, _ = elastic.NewClient(http.DefaultClient, "http://ela.spdata.jianyu360.com")
|
|
|
-
|
|
|
- es_type, es_index = "unique_qy", "unique_qy"
|
|
|
-
|
|
|
- q := map[string]interface{}{
|
|
|
- "check_history": map[string]interface{}{
|
|
|
- "$exists": 0,
|
|
|
- },
|
|
|
- }
|
|
|
- sess := QfwMgo85.GetMgoConn()
|
|
|
- defer QfwMgo85.DestoryMongoConn(sess)
|
|
|
- //多线程升索引
|
|
|
- pool_es := make(chan bool, 3)
|
|
|
- wg_es := &sync.WaitGroup{}
|
|
|
- it := sess.DB(QfwMgo85.DbName).C("winner_err_new").Find(&q).Iter()
|
|
|
- total, isOK := 0, 0
|
|
|
- for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
|
|
|
- if total%100 == 0 {
|
|
|
- log.Println("current index", total, isOK)
|
|
|
- }
|
|
|
- name := ObjToString(tmp["name"])
|
|
|
- tmpid := BsonTOStringId(tmp["_id"])
|
|
|
- pool_es <- true
|
|
|
- wg_es.Add(1)
|
|
|
-
|
|
|
- go func(name string, tmpid string) {
|
|
|
- defer func() {
|
|
|
- <-pool_es
|
|
|
- wg_es.Done()
|
|
|
- }()
|
|
|
- //start := int(time.Now().Unix())
|
|
|
- new_name,b,score,_ :=dealWithNameScoreRules(name)
|
|
|
- //log.Println("耗时:",int(time.Now().Unix())-start,"秒",b,name,new_name,tmpid)
|
|
|
- if new_name != "" && b {
|
|
|
- isOK++
|
|
|
- QfwMgo85.UpdateById("winner_err_new", tmpid, map[string]interface{}{
|
|
|
- "$set": map[string]interface{}{
|
|
|
- "is_word": 1,
|
|
|
- "name_word" : new_name,
|
|
|
- "score":score,
|
|
|
-
|
|
|
- },
|
|
|
- })
|
|
|
- } else {
|
|
|
- QfwMgo85.UpdateById("winner_err_new", tmpid, map[string]interface{}{
|
|
|
- "$set": map[string]interface{}{
|
|
|
-
|
|
|
- "is_word": -1,
|
|
|
- "name_word" : new_name,
|
|
|
- "score":score,
|
|
|
-
|
|
|
- },
|
|
|
- })
|
|
|
- }
|
|
|
|
|
|
- }(name, tmpid)
|
|
|
- tmp = make(map[string]interface{})
|
|
|
- }
|
|
|
|
|
|
- wg_es.Wait()
|
|
|
|
|
|
- log.Println("is over", total, isOK)
|
|
|
-}
|
|
|
|
|
|
|
|
|
-func TemporaryTestNewData() {
|
|
|
- log.Println("测试......导出新数据")
|
|
|
- QfwMgo85 = &MongodbSim{
|
|
|
- MongodbAddr: "172.17.4.187:27082,172.17.145.163:27083",
|
|
|
- Size: 5,
|
|
|
- DbName: "mixdata",
|
|
|
- UserName: "fengweiqiang",
|
|
|
- PassWord: "fwq@123123",
|
|
|
- }
|
|
|
- QfwMgo85.InitPool()
|
|
|
|
|
|
- q := map[string]interface{}{
|
|
|
- "is_word":map[string]interface{}{
|
|
|
- "$exists":1,
|
|
|
- },
|
|
|
- }
|
|
|
- sess := QfwMgo85.GetMgoConn()
|
|
|
- defer QfwMgo85.DestoryMongoConn(sess)
|
|
|
- it := sess.DB(QfwMgo85.DbName).C("winner_err_new").Find(&q).Select(map[string]interface{}{
|
|
|
- "name":1,
|
|
|
- "name_word":1,
|
|
|
- "is_word":1,
|
|
|
- }).Iter()
|
|
|
- total:=0
|
|
|
- for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
|
|
|
- if total % 100 == 0 {
|
|
|
- log.Println("current index",total)
|
|
|
- }
|
|
|
- savedict := tmp
|
|
|
- QfwMgo85.Save("winner_err_new_word",savedict)
|
|
|
-
|
|
|
- tmp = make(map[string]interface{})
|
|
|
- }
|
|
|
|
|
|
- log.Println("is over",total)
|
|
|
-
|
|
|
-}
|
|
|
|
|
|
|
|
|
|