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

Method BuildIndex

models/elasticsearch.go:466–494  ·  view source on GitHub ↗

创建索引

(es ElasticSearchData)

Source from the content-addressed store, hash-verified

464
465//创建索引
466func (this *ElasticSearchClient) BuildIndex(es ElasticSearchData) (err error) {
467 if !this.On {
468 return
469 }
470
471 var (
472 js []byte
473 _id string
474 )
475
476 if orm.Debug {
477 beego.Info("创建索引--------start--------")
478 fmt.Printf("内容:%+v\n", es)
479 beego.Info("创建索引-------- end --------")
480 }
481
482 es.Content = this.html2Text(es.Content)
483
484 if es.BookId > 0 {
485 _id = fmt.Sprintf("doc_%v", es.Id)
486 } else {
487 _id = fmt.Sprintf("book_%v", es.Id)
488 }
489 api := this.Host + this.Index + "/" + this.Type + "/" + _id
490 if js, err = json.Marshal(es); err == nil {
491 err = utils.HandleResponse(this.post(api).Body(js).Response())
492 }
493 return
494}
495
496// 查询分词
497func (this *ElasticSearchClient) SegWords(keyword string) string {

Callers 2

SaveBookMethod · 0.95
EditBookMethod · 0.95

Calls 4

html2TextMethod · 0.95
postMethod · 0.95
HandleResponseFunction · 0.92
ResponseMethod · 0.80

Tested by

no test coverage detected