MCPcopy Index your code
hub / github.com/TruthHun/DocHub / BuildIndex

Method BuildIndex

models/ElasticSearchModel.go:370–393  ·  view source on GitHub ↗

创建索引

(es ElasticSearchData)

Source from the content-addressed store, hash-verified

368
369//创建索引
370func (this *ElasticSearchClient) BuildIndex(es ElasticSearchData) (err error) {
371 var (
372 js []byte
373 resp *http.Response
374 )
375 if !this.On {
376 return
377 }
378 if helper.Debug {
379 beego.Info("创建索引--------start--------")
380 fmt.Printf("%+v\n", es)
381 beego.Info("创建索引-------- end --------")
382 }
383 api := this.Host + this.Index + "/" + this.Type + "/" + strconv.Itoa(es.Id)
384 if js, err = json.Marshal(es); err == nil {
385 if resp, err = this.post(api).Body(js).Response(); err == nil {
386 if resp.StatusCode >= 300 || resp.StatusCode < 200 {
387 b, _ := ioutil.ReadAll(resp.Body)
388 err = errors.New("生成索引失败:" + resp.Status + ";" + string(b))
389 }
390 }
391 }
392 return
393}
394
395//查询索引量
396//@return count 统计数据

Callers 1

BuildIndexByIdMethod · 0.95

Calls 2

postMethod · 0.95
ResponseMethod · 0.80

Tested by

no test coverage detected