no message
parent
14b902f429
commit
9c71c7b022
|
@ -127,6 +127,7 @@ func InitELK() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
func initMysql(mysqlconf *config.MysqlConfig) *sql.DB {
|
||||
cnn := fmt.Sprintf("%s:%s@tcp(%s:3306)/%s?charset=utf8", mysqlconf.UserName, mysqlconf.Password,
|
||||
mysqlconf.Addr, mysqlconf.Db)
|
||||
|
|
|
@ -144,27 +144,13 @@ func PortDocumentToElasticsearch(tblname string) error {
|
|||
if nil != e {
|
||||
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{}
|
||||
e = db.GetMysqlClient().Query2("describe "+tblname, &columns)
|
||||
if nil != e {
|
||||
logger.Debug(e.Error())
|
||||
return e
|
||||
}
|
||||
if existed, _ := db.GetElastic().IndexExisted(tblname); existed {
|
||||
for _, v := range ret {
|
||||
e := InsertDocToElaticSearch(v)
|
||||
if nil != e {
|
||||
log.Print(e.Error())
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if existed, _ := db.GetElastic().IndexExisted(tblname); !existed {
|
||||
props := map[string]interface{}{}
|
||||
mapping := map[string]interface{}{
|
||||
"settings": map[string]interface{}{
|
||||
|
|
Loading…
Reference in New Issue