查询索引是否存在 @return err nil表示索引存在,否则表示不存在
()
| 450 | //查询索引是否存在 |
| 451 | //@return err nil表示索引存在,否则表示不存在 |
| 452 | func (this *ElasticSearchClient) existIndex() (err error) { |
| 453 | var resp *http.Response |
| 454 | api := this.Host + this.Index |
| 455 | if resp, err = this.get(api).Response(); err == nil { |
| 456 | if resp.StatusCode >= 300 || resp.StatusCode < 200 { |
| 457 | b, _ := ioutil.ReadAll(resp.Body) |
| 458 | err = errors.New(resp.Status + ":" + string(b)) |
| 459 | } |
| 460 | } |
| 461 | return |
| 462 | } |
| 463 | |
| 464 | //创建索引 |
| 465 | //@return err 创建索引 |