|
@@ -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)
|
|
|
}
|
|
|
}
|