|
@@ -140,15 +140,25 @@ func SearchReport(keyWord string, classifyIdFirsts []int, classifyIdSeconds []in
|
|
|
|
|
|
func SearchReportV2(keyWord string, classifyIdFirsts []int, classifyIdSeconds []int, pageIndex, pageSize int) (searchResp *elastic.SearchResult, total int64, err error) {
|
|
|
indices := []string{utils.EsReportIndexName, utils.MINI_REPORT_INDEX_NAME}
|
|
|
- query := elastic.NewBoolQuery()
|
|
|
- query = query.Must(elastic.NewMatchPhraseQuery("Title", keyWord)).Boost(5)
|
|
|
- query = query.Should(elastic.NewMatchPhraseQuery("State", 1))
|
|
|
- query = query.Should(elastic.NewMatchPhraseQuery("PublishState", 2))
|
|
|
- sort := elastic.NewFieldSort("PublishTime.keyword").Desc()
|
|
|
+ query := elastic.NewBoolQuery().
|
|
|
+ Filter(
|
|
|
+ elastic.NewBoolQuery().Should(
|
|
|
+ elastic.NewTermQuery("PublishState", 2),
|
|
|
+ elastic.NewTermQuery("State", 1),
|
|
|
+ ),
|
|
|
+ ).
|
|
|
+ Must(
|
|
|
+ elastic.NewBoolQuery().Should(
|
|
|
+ elastic.NewMatchPhraseQuery("Title", keyWord).Boost(5),
|
|
|
+ ),
|
|
|
+ )
|
|
|
+
|
|
|
+ sort1 := elastic.NewFieldSort("PublishTime.keyword").Desc()
|
|
|
+ sort2 := elastic.NewScoreSort().Desc()
|
|
|
searchResp, err = utils.EsClient.Search().
|
|
|
Index(indices...).
|
|
|
Query(query).
|
|
|
- SortBy(sort).
|
|
|
+ SortBy(sort1, sort2).
|
|
|
Highlight(elastic.NewHighlight().
|
|
|
PreTags("<span class=\"report-title_color\">").
|
|
|
PostTags("</span>").
|