Roc 2 周之前
父節點
當前提交
2ec2141b18
共有 2 個文件被更改,包括 47 次插入4 次删除
  1. 16 1
      controllers/llm/abstract.go
  2. 31 3
      services/elastic/wechat_article_abstract.go

+ 16 - 1
controllers/llm/abstract.go

@@ -90,7 +90,22 @@ func (c *AbstractController) List() {
 			"WechatArticleAbstractId": "desc",
 		}
 
-		tmpTotal, list, err := elastic.WechatArticleAbstractEsSearch(keyWord, tagId, startSize, pageSize, sortMap)
+		obj := new(rag.WechatPlatform)
+		platformList, err := obj.GetListByCondition(` AND enabled = 1 `, []interface{}{}, 0, 100000)
+		if err != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取失败,Err:" + err.Error()
+			return
+		}
+		platformIdList := make([]int, 0)
+		for _, v := range platformList {
+			platformIdList = append(platformIdList, v.WechatPlatformId)
+		}
+		tagList := make([]int, 0)
+		if tagId > 0 {
+			tagList = append(tagList, tagId)
+		}
+		tmpTotal, list, err := elastic.WechatArticleAbstractEsSearch(keyWord, tagList, platformIdList, startSize, pageSize, sortMap)
 		if err != nil {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取失败,Err:" + err.Error()

+ 31 - 3
services/elastic/wechat_article_abstract.go

@@ -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...))
 	}
 
 	// 名字匹配