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

Method Count

models/ElasticSearchModel.go:398–419  ·  view source on GitHub ↗

查询索引量 @return count 统计数据 @return err 错误

()

Source from the content-addressed store, hash-verified

396//@return count 统计数据
397//@return err 错误
398func (this *ElasticSearchClient) Count() (count int, err error) {
399 if !this.On {
400 err = errors.New("未启用ElasticSearch")
401 return
402 }
403 api := this.Host + this.Index + "/" + this.Type + "/_count"
404 if resp, errResp := this.get(api).Response(); errResp != nil {
405 err = errResp
406 } else {
407 b, _ := ioutil.ReadAll(resp.Body)
408 body := string(b)
409 if resp.StatusCode >= http.StatusMultipleChoices || resp.StatusCode < http.StatusOK {
410 err = errors.New(resp.Status + ";" + body)
411 } else {
412 var cnt ElasticSearchCount
413 if err = json.Unmarshal(b, &cnt); err == nil {
414 count = cnt.Count
415 }
416 }
417 }
418 return
419}
420
421//删除索引
422//@param id 索引id

Callers 10

CommentMethod · 0.80
GetMethod · 0.80
SegWordFunction · 0.80
TestValidFunction · 0.80
execValidFunction · 0.80
RegMethod · 0.80
SearchFunction · 0.80
CountFunction · 0.80
BuildSitemapMethod · 0.80
AddWordsMethod · 0.80

Calls 2

getMethod · 0.95
ResponseMethod · 0.80

Tested by 1

TestValidFunction · 0.64