完善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{
|
||||
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
|
||||
}
|
Loading…
Reference in New Issue