完善elasticsearch接口,添加中文精确匹配软件的实现。

master
a7458969 2020-04-24 22:56:24 +08:00
parent fbf25b0abf
commit 69f4f91445
2 changed files with 19 additions and 2 deletions

View File

@ -117,7 +117,7 @@ func (p *ElkEngine)Update(index string,types string,id string,data map[string]in
}
func (p *ElkEngine)CreateIndex(index string,typemaping string) error{
if nil != p {
exists, err := p.cli.IndexExists("elastic_index").Do(context.Background())
exists, err := p.cli.IndexExists(index).Do(context.Background())
if err != nil {
// Handle error
log.Print(err)
@ -137,4 +137,21 @@ func (p *ElkEngine)CreateIndex(index string,typemaping string) error{
}
}
return errors.New(ERROR_PTR)
}
func (p *ElkEngine)IndexExisted(index string) (bool,error ){
if nil != p {
exists, err := p.cli.IndexExists(index).Do(context.Background())
if exists{
return true,nil
}
if err != nil {
// Handle error
log.Print(err)
return false,err
}
return false,nil
}
return false,nil
}

View File

@ -43,7 +43,7 @@ func InitRedis() {
func InitElasticSearch(){
e := db.GetElastic().CreateIndex("hardware",model.HardwareTypeMapping())
if nil != e{
log.Print(e.Error())
}
}
func InitLogs() {