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

Method CreateIndex

search-elasticsearch/es_operator.go:52–68  ·  view source on GitHub ↗
(ctx context.Context, indexName string, mapping string)

Source from the content-addressed store, hash-verified

50}
51
52func (op *Operator) CreateIndex(ctx context.Context, indexName string, mapping string) (err error) {
53 log.Debugf("try to create index: %s", indexName)
54 exist, err := op.C.IndexExists(indexName).Do(ctx)
55 if err != nil {
56 return err
57 }
58 if exist {
59 log.Debugf("index %s already exists", indexName)
60 return nil
61 }
62 _, err = op.C.CreateIndex(indexName).BodyString(mapping).Do(ctx)
63 if err != nil {
64 log.Errorf("create index %s failed: %s", indexName, err.Error())
65 return err
66 }
67 return nil
68}
69
70func (op *Operator) QueryDoc(ctx context.Context, indexName string,
71 query elastic.Query, sort *elastic.FieldSort, cols *elastic.FetchSourceContext,

Callers 3

TestSearchEngine_IndexFunction · 0.95
tryToCreateIndexMethod · 0.80
ConfigReceiverMethod · 0.80

Calls 1

DoMethod · 0.80

Tested by 1

TestSearchEngine_IndexFunction · 0.76