完善elasticsearch接口,添加中文精确匹配软件的实现。
parent
fbf25b0abf
commit
69f4f91445
|
@ -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{
|
func (p *ElkEngine)CreateIndex(index string,typemaping string) error{
|
||||||
if nil != p {
|
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 {
|
if err != nil {
|
||||||
// Handle error
|
// Handle error
|
||||||
log.Print(err)
|
log.Print(err)
|
||||||
|
@ -137,4 +137,21 @@ func (p *ElkEngine)CreateIndex(index string,typemaping string) error{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return errors.New(ERROR_PTR)
|
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
|
||||||
}
|
}
|
2
main.go
2
main.go
|
@ -43,7 +43,7 @@ func InitRedis() {
|
||||||
func InitElasticSearch(){
|
func InitElasticSearch(){
|
||||||
e := db.GetElastic().CreateIndex("hardware",model.HardwareTypeMapping())
|
e := db.GetElastic().CreateIndex("hardware",model.HardwareTypeMapping())
|
||||||
if nil != e{
|
if nil != e{
|
||||||
log.Print(e.Error())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func InitLogs() {
|
func InitLogs() {
|
||||||
|
|
Loading…
Reference in New Issue