no message
parent
14b902f429
commit
9c71c7b022
|
@ -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)
|
||||||
|
|
|
@ -81,7 +81,7 @@ func InsertDocToElaticSearch(doc Doc) error {
|
||||||
matchPhraseQuery := elastic.NewMatchQuery("title", doc.Title)
|
matchPhraseQuery := elastic.NewMatchQuery("title", doc.Title)
|
||||||
existedHardware, e := QueryHardwares(matchPhraseQuery, 10, 0)
|
existedHardware, e := QueryHardwares(matchPhraseQuery, 10, 0)
|
||||||
log.Print(e, existedHardware)
|
log.Print(e, existedHardware)
|
||||||
|
|
||||||
for _, v := range existedHardware {
|
for _, v := range existedHardware {
|
||||||
if v.Name == doc.Title {
|
if v.Name == doc.Title {
|
||||||
log.Print(v.ID)
|
log.Print(v.ID)
|
||||||
|
@ -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{}{
|
||||||
|
|
Loading…
Reference in New Issue