1234567891011121314151617181920212223242526272829303132333435 |
- package elastic
- import (
- "context"
- "eta_gn/eta_index_lib/models"
- "eta_gn/eta_index_lib/utils"
- "fmt"
- )
- // EsAddOrEditEdbInfoData 新增/修改es中的指标数据
- func EsAddOrEditEdbInfoData(indexName, docId string, item *models.EdbInfoList) (err error) {
- defer func() {
- if err != nil {
- fmt.Println("EsAddOrEditData Err:", err.Error())
- }
- }()
- client := utils.EsClient
- if err != nil {
- return
- }
- resp, err := client.Index().Index(indexName).Id(docId).BodyJson(item).Do(context.Background())
- if err != nil {
- fmt.Println("新增失败:", err.Error())
- return err
- }
- fmt.Println(resp)
- if resp.Status == 0 {
- fmt.Println("新增成功", resp.Result)
- err = nil
- } else {
- fmt.Println("AddData", resp.Status, resp.Result)
- }
- return
- }
|