|
@@ -29,6 +29,7 @@ func NewClient() (client *elastic.Client, err error) {
|
|
|
elastic.SetBasicAuth(ES_USERNAME, ES_PASSWORD),
|
|
|
elastic.SetTraceLog(log.New(logFile, "ES-TRACE: ", 0)),
|
|
|
elastic.SetSniff(false), elastic.SetErrorLog(errorlog))
|
|
|
+ defer logFile.Close()
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -89,6 +90,7 @@ func EsAddOrEditData(indexName, docId string, item *ElasticTestArticleDetail) (e
|
|
|
} else {
|
|
|
fmt.Println("EditData", resp.Status, resp.Result)
|
|
|
}
|
|
|
+ client.CloseIndex(indexName)
|
|
|
} else {
|
|
|
resp, err := client.Index().Index(indexName).Id(docId).BodyJson(item).Do(context.Background())
|
|
|
if err != nil {
|