瀏覽代碼

产业排序优化

xingzai 3 年之前
父節點
當前提交
58bc760b77
共有 4 個文件被更改,包括 8 次插入6 次删除
  1. 2 1
      controllers/report.go
  2. 1 1
      controllers/search.go
  3. 2 3
      main.go
  4. 3 1
      services/elastic.go

+ 2 - 1
controllers/report.go

@@ -127,8 +127,9 @@ func (this *ReportController) IndustryList() {
 	if orderColumn == "NewTime" {
 		orderSrt = "update_time DESC"
 	} else {
-		orderSrt = "man.recommended_index,update_time DESC"
+		orderSrt = "man.recommended_index DESC,update_time DESC"
 	}
+	fmt.Println(orderSrt)
 	//全部都是置顶
 	if totalTop >= currentIndex*pageSize {
 		listTop, err := models.GetIndustrialManagementTopAll(ChartPermissionId, uid, startSize, pageSize)

+ 1 - 1
controllers/search.go

@@ -106,7 +106,7 @@ func (this *SearchController) SearchList() {
 		keyWordItem.CreateTime = time.Now()
 		go models.AddSearchKeyWord(keyWordItem)
 	}
-
+	fmt.Println(len(result))
 	resp := new(models.SearchResp)
 	page := paging.GetPaging(currentIndex, pageSize, int(total))
 	resp.Paging = page

+ 2 - 3
main.go

@@ -9,8 +9,8 @@ import (
 	"runtime"
 	"time"
 
-	"github.com/astaxie/beego/context"
 	"github.com/astaxie/beego"
+	"github.com/astaxie/beego/context"
 )
 
 func main() {
@@ -24,7 +24,6 @@ func main() {
 	beego.Run()
 }
 
-
 func Recover(ctx *context.Context) {
 	if err := recover(); err != nil {
 		if err == beego.ErrAbort {
@@ -54,4 +53,4 @@ func Recover(ctx *context.Context) {
 		go utils.SendEmail(utils.APPNAME+"崩了"+time.Now().Format("2006-01-02 15:04:05"), stack, utils.EmailSendToUsers)
 	}
 	return
-}
+}

+ 3 - 1
services/elastic.go

@@ -769,11 +769,13 @@ func EsMultiMatchFunctionScoreQueryTimeSort(indexName, keyWord string, startSize
 	highlight := elastic.NewHighlight()
 	highlight = highlight.Fields(elastic.NewHighlighterField("Title"), elastic.NewHighlighterField("BodyText"))
 	highlight = highlight.PreTags("<font color='red'>").PostTags("</font>")
-	request := client.Search(indexName).Highlight(highlight).Sort("PublishDate", false).From(startSize).Size(pageSize).Query(boolquery)
+	request := client.Search(indexName).Highlight(highlight).Sort("PublishDate", false).Query(boolquery)
 	searchByMatch, err := request.Do(context.Background())
+
 	if searchByMatch != nil {
 		matchResult, _ := json.Marshal(searchByMatch)
 		utils.FileLog.Info("%s", string(matchResult))
+		fmt.Println(len(searchByMatch.Hits.Hits))
 		if searchByMatch.Hits != nil {
 			for _, v := range searchByMatch.Hits.Hits {
 				articleJson, err := v.Source.MarshalJSON()