删除索引 @param id 索引id @return err 错误
(id int)
| 422 | //@param id 索引id |
| 423 | //@return err 错误 |
| 424 | func (this *ElasticSearchClient) DeleteIndex(id int) (err error) { |
| 425 | api := this.Host + this.Index + "/" + this.Type + "/" + strconv.Itoa(id) |
| 426 | if resp, errResp := this.delete(api).Response(); errResp != nil { |
| 427 | err = errResp |
| 428 | } else { |
| 429 | if resp.StatusCode >= 300 || resp.StatusCode < 200 { |
| 430 | b, _ := ioutil.ReadAll(resp.Body) |
| 431 | err = errors.New("删除索引失败:" + resp.Status + ";" + string(b)) |
| 432 | } |
| 433 | } |
| 434 | return |
| 435 | } |
| 436 | |
| 437 | //检验es服务能否连通 |
| 438 | func (this *ElasticSearchClient) ping() error { |
no test coverage detected