检验es服务能否连通
()
| 436 | |
| 437 | //检验es服务能否连通 |
| 438 | func (this *ElasticSearchClient) ping() error { |
| 439 | resp, err := this.get(this.Host).Response() |
| 440 | if err != nil { |
| 441 | return err |
| 442 | } |
| 443 | if resp.StatusCode >= 300 || resp.StatusCode < 200 { |
| 444 | body, _ := ioutil.ReadAll(resp.Body) |
| 445 | err = errors.New(resp.Status + ";" + string(body)) |
| 446 | } |
| 447 | return err |
| 448 | } |
| 449 | |
| 450 | //查询索引是否存在 |
| 451 | //@return err nil表示索引存在,否则表示不存在 |