MCPcopy Index your code
hub / github.com/apache/answer-plugins / ConfigReceiver

Method ConfigReceiver

search-elasticsearch/es.go:203–220  ·  view source on GitHub ↗
(config []byte)

Source from the content-addressed store, hash-verified

201}
202
203func (s *SearchEngine) ConfigReceiver(config []byte) error {
204 conf := &SearchEngineConfig{}
205 _ = json.Unmarshal(config, conf)
206 s.Config = conf
207
208 log.Debugf("try to init es client: %s", conf.Endpoints)
209
210 operator, err := NewOperator(strings.Split(conf.Endpoints, ","), conf.Username, conf.Password)
211 if err != nil {
212 return fmt.Errorf("init es client error: %w", err)
213 }
214 s.Operator = operator
215 err = s.Operator.CreateIndex(context.Background(), s.getIndexName(), indexJson)
216 if err != nil {
217 return fmt.Errorf("create index error: %w", err)
218 }
219 return nil
220}
221
222func (s *SearchEngine) getIndexName() string {
223 return "answer_post"

Callers

nothing calls this directly

Calls 3

getIndexNameMethod · 0.95
NewOperatorFunction · 0.85
CreateIndexMethod · 0.80

Tested by

no test coverage detected