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

Function NewElasticSearchClient

models/ElasticSearchModel.go:106–124  ·  view source on GitHub ↗

创建全文搜索客户端

(configElasticSearch ...ElasticSearchClient)

Source from the content-addressed store, hash-verified

104
105//创建全文搜索客户端
106func NewElasticSearchClient(configElasticSearch ...ElasticSearchClient) (client *ElasticSearchClient) {
107 if len(configElasticSearch) > 0 {
108 client = &configElasticSearch[0]
109 }
110 //并未设置超时配置项
111 timeout := helper.GetConfigInt64(ConfigCateElasticSearch, "timeout")
112 if timeout <= 0 { //默认超时时间为10秒
113 timeout = 10
114 }
115 client = &ElasticSearchClient{
116 Host: helper.GetConfig(ConfigCateElasticSearch, "host", "http://localhost:9200/"),
117 Index: helper.GetConfig(ConfigCateElasticSearch, "index", "dochub"),
118 Type: "fulltext",
119 On: helper.GetConfigBool(ConfigCateElasticSearch, "on"),
120 Timeout: time.Duration(timeout) * time.Second,
121 }
122 client.Host = strings.TrimRight(client.Host, "/") + "/"
123 return
124}
125
126//初始化全文搜索客户端,包括检查索引是否存在,mapping设置等
127func (this *ElasticSearchClient) Init() (err error) {

Callers 3

DocumentProcessFunction · 0.85
RecoverFromRecycleMethod · 0.85
RemoveToRecycleMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected