|
@@ -207,65 +207,6 @@ func EsAddOrEditEnglishReport(indexName, docId string, item *models.ElasticEngli
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-func EsAddOrEditSaCompare(indexName, docId string, item *saModel.SaCompareElastic) (err error) {
|
|
|
- defer func() {
|
|
|
- if err != nil {
|
|
|
- fmt.Println("EsAddOrEditSaCompare Err:", err.Error())
|
|
|
- go alarm_msg.SendAlarmMsg("新增编辑es语义分析文档对比 EsAddOrEditSaCompare,Err:"+err.Error(), 3)
|
|
|
- }
|
|
|
- }()
|
|
|
- client := utils.EsClient
|
|
|
-
|
|
|
- searchById, err := client.Get().Index(indexName).Id(docId).Do(context.Background())
|
|
|
- if err != nil {
|
|
|
- if strings.Contains(err.Error(), "404") {
|
|
|
- err = nil
|
|
|
- } else {
|
|
|
- fmt.Println("Get Err" + err.Error())
|
|
|
- return
|
|
|
- }
|
|
|
- }
|
|
|
- if searchById != nil && searchById.Found {
|
|
|
- resp, e := client.Update().Index(indexName).Id(docId).Doc(map[string]interface{}{
|
|
|
- "SaCompareId": item.SaCompareId,
|
|
|
- "ClassifyName": item.ClassifyName,
|
|
|
- "ClassifyId": item.ClassifyId,
|
|
|
- "Title": item.Title,
|
|
|
- "ResultImg": item.ResultImg,
|
|
|
- "CreateTime": item.CreateTime,
|
|
|
- "ModifyTime": item.ModifyTime,
|
|
|
- "SysAdminId": item.SysAdminId,
|
|
|
- "SysAdminName": item.SysAdminName,
|
|
|
- }).Do(context.Background())
|
|
|
- if e != nil {
|
|
|
- err = e
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- if resp.Status == 0 {
|
|
|
- fmt.Println("修改成功" + docId)
|
|
|
- err = nil
|
|
|
- } else {
|
|
|
- fmt.Println("EditData", resp.Status, resp.Result)
|
|
|
- }
|
|
|
- } else {
|
|
|
- resp, e := client.Index().Index(indexName).Id(docId).BodyJson(item).Do(context.Background())
|
|
|
- if e != nil {
|
|
|
- err = e
|
|
|
- fmt.Println("新增失败:", err.Error())
|
|
|
- return
|
|
|
- }
|
|
|
- if resp.Status == 0 && resp.Result == "created" {
|
|
|
- fmt.Println("新增成功" + docId)
|
|
|
- return
|
|
|
- } else {
|
|
|
- fmt.Println("AddData", resp.Status, resp.Result)
|
|
|
- }
|
|
|
- }
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
|
|
|
func EsAddOrEditSaDoc(indexName, docId string, item *saModel.ElasticSaDoc) (err error) {
|
|
|
defer func() {
|