(config []byte)
| 201 | } |
| 202 | |
| 203 | func (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 | |
| 222 | func (s *SearchEngine) getIndexName() string { |
| 223 | return "answer_post" |
nothing calls this directly
no test coverage detected