创建索引 @return err 创建索引
()
| 464 | //创建索引 |
| 465 | //@return err 创建索引 |
| 466 | func (this *ElasticSearchClient) createIndex() (err error) { |
| 467 | var resp *http.Response |
| 468 | api := this.Host + this.Index |
| 469 | if resp, err = this.put(api).Response(); err == nil { |
| 470 | if resp.StatusCode >= 300 || resp.StatusCode < 200 { |
| 471 | b, _ := ioutil.ReadAll(resp.Body) |
| 472 | err = errors.New(resp.Status + ":" + string(b)) |
| 473 | } |
| 474 | } |
| 475 | return |
| 476 | } |
| 477 | |
| 478 | //put请求 |
| 479 | func (this *ElasticSearchClient) put(api string) (req *httplib.BeegoHTTPRequest) { |