|
@@ -134,7 +134,20 @@ func WechatArticleAbstractEsDel(docId string) (err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-func WechatArticleAbstractEsSearch(keywordStr string, tagId, from, size int, sortMap map[string]string) (total int64, list []*WechatArticleAbstractItem, err error) {
|
|
|
+// WechatArticleAbstractEsSearch
|
|
|
+// @Description: 搜索
|
|
|
+// @author: Roc
|
|
|
+// @datetime 2025-03-13 19:54:54
|
|
|
+// @param keywordStr string
|
|
|
+// @param tagIdList []int
|
|
|
+// @param platformIdList []int
|
|
|
+// @param from int
|
|
|
+// @param size int
|
|
|
+// @param sortMap map[string]string
|
|
|
+// @return total int64
|
|
|
+// @return list []*WechatArticleAbstractItem
|
|
|
+// @return err error
|
|
|
+func WechatArticleAbstractEsSearch(keywordStr string, tagIdList, platformIdList []int, from, size int, sortMap map[string]string) (total int64, list []*WechatArticleAbstractItem, err error) {
|
|
|
indexName := EsWechatArticleAbstractName
|
|
|
list = make([]*WechatArticleAbstractItem, 0)
|
|
|
defer func() {
|
|
@@ -145,8 +158,23 @@ func WechatArticleAbstractEsSearch(keywordStr string, tagId, from, size int, sor
|
|
|
|
|
|
query := elastic.NewBoolQuery()
|
|
|
|
|
|
- if tagId > 0 {
|
|
|
- query = query.Must(elastic.NewTermsQuery("TagIdList", tagId))
|
|
|
+ if len(tagIdList) > 0 {
|
|
|
+ termsList := make([]interface{}, 0)
|
|
|
+ for _, v := range tagIdList {
|
|
|
+ termsList = append(termsList, v)
|
|
|
+ }
|
|
|
+ query = query.Must(elastic.NewTermsQuery("TagIdList", termsList...))
|
|
|
+ }
|
|
|
+ if len(platformIdList) <= 0 {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ {
|
|
|
+ termsList := make([]interface{}, 0)
|
|
|
+ for _, v := range platformIdList {
|
|
|
+ termsList = append(termsList, v)
|
|
|
+ }
|
|
|
+ query = query.Must(elastic.NewTermsQuery("WechatPlatformId", termsList...))
|
|
|
}
|
|
|
|
|
|
// 名字匹配
|