فهرست منبع

修改日志路径

rdluck 4 سال پیش
والد
کامیت
87ccfe7bbf
2فایلهای تغییر یافته به همراه12 افزوده شده و 14 حذف شده
  1. 9 6
      services/elastic.go
  2. 3 8
      services/task.go

+ 9 - 6
services/elastic.go

@@ -16,7 +16,12 @@ import (
 
 func NewClient() (client *elastic.Client, err error) {
 	errorlog := log.New(os.Stdout, "APP", log.LstdFlags)
-	file := "./rdlucklog/eslog.log"
+	file := ""
+	if utils.RunMode == "release" {
+		file = `/data/rdlucklog/hongze_cygx/eslog.log`
+	} else {
+		file = `./rdlucklog/eslog.log`
+	}
 	logFile, _ := os.OpenFile(file, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0766)
 	client, err = elastic.NewClient(
 		elastic.SetURL(ES_URL),
@@ -70,9 +75,9 @@ func EsAddOrEditData(indexName, docId string, item *ElasticTestArticleDetail) (e
 	}
 	if searchById != nil && searchById.Found {
 		resp, err := client.Update().Index(indexName).Id(docId).Doc(map[string]interface{}{
-			"BodyText": item.BodyText,
-			"Title":    item.Title,
-			"PublishDate":item.PublishDate,
+			"BodyText":    item.BodyText,
+			"Title":       item.Title,
+			"PublishDate": item.PublishDate,
 		}).Do(context.Background())
 		if err != nil {
 			return err
@@ -447,8 +452,6 @@ func EsMultiMatchFunctionScoreQuery(indexName, keyWord string, startSize, pageSi
 				searchItem.Title = title
 				searchItem.PublishDate = article.PublishDate
 
-
-
 				result = append(result, searchItem)
 			}
 		}

+ 3 - 8
services/task.go

@@ -16,6 +16,7 @@ func Task() {
 		toolbox.StartTask()
 	}
 	//SyncTacticsList()
+	//CreateIndex()
 	fmt.Println("end")
 }
 
@@ -172,7 +173,7 @@ searchItem.Title = title
 searchItem.PublishDate = article.PublishDate
  */
 func CreateIndex() {
-	indexName := utils.IndexName
+	indexName := "cygx_article_test"//utils.IndexName
 	mappingJson := `{
   "mappings": {
     "dynamic": true,
@@ -182,31 +183,25 @@ func CreateIndex() {
       },
       "BodyText": {
         "type": "text",
-        "analyzer": "ik_smart",
         "term_vector": "with_positions_offsets"
       },
       "PublishDate": {
-        "type": "text",
-        "analyzer": "ik_smart"
+        "type": "text"
       },
       "SubCategoryName": {
         "type": "text",
-        "analyzer": "ik_smart",
         "term_vector": "with_positions_offsets"
       },
       "Title": {
         "type": "text",
-        "analyzer": "ik_smart",
         "term_vector": "with_positions_offsets"
       },
       "TitleEn": {
         "type": "text",
-        "analyzer": "ik_smart",
         "term_vector": "with_positions_offsets"
       },
       "UpdateFrequency": {
         "type": "text",
-        "analyzer": "ik_smart",
         "term_vector": "with_positions_offsets"
       }
     }