no message

master
zcy 2021-07-25 02:05:35 +08:00
parent 14b902f429
commit 9c71c7b022
2 changed files with 3 additions and 16 deletions

View File

@ -127,6 +127,7 @@ func InitELK() {
} }
} }
func initMysql(mysqlconf *config.MysqlConfig) *sql.DB { func initMysql(mysqlconf *config.MysqlConfig) *sql.DB {
cnn := fmt.Sprintf("%s:%s@tcp(%s:3306)/%s?charset=utf8", mysqlconf.UserName, mysqlconf.Password, cnn := fmt.Sprintf("%s:%s@tcp(%s:3306)/%s?charset=utf8", mysqlconf.UserName, mysqlconf.Password,
mysqlconf.Addr, mysqlconf.Db) mysqlconf.Addr, mysqlconf.Db)

View File

@ -144,27 +144,13 @@ func PortDocumentToElasticsearch(tblname string) error {
if nil != e { if nil != e {
log.Print(e.Error()) log.Print(e.Error())
} }
insert, err := json.Marshal(ret)
if nil != err {
log.Print(err)
}
log.Print(len(ret))
log.Print(string(insert))
columns := []Field{} columns := []Field{}
e = db.GetMysqlClient().Query2("describe "+tblname, &columns) e = db.GetMysqlClient().Query2("describe "+tblname, &columns)
if nil != e { if nil != e {
logger.Debug(e.Error()) logger.Debug(e.Error())
return e return e
} }
if existed, _ := db.GetElastic().IndexExisted(tblname); existed { if existed, _ := db.GetElastic().IndexExisted(tblname); !existed {
for _, v := range ret {
e := InsertDocToElaticSearch(v)
if nil != e {
log.Print(e.Error())
}
}
} else {
props := map[string]interface{}{} props := map[string]interface{}{}
mapping := map[string]interface{}{ mapping := map[string]interface{}{
"settings": map[string]interface{}{ "settings": map[string]interface{}{