|
@@ -46,8 +46,8 @@ type ElasticComprehensiveDetail struct {
|
|
|
}
|
|
|
|
|
|
//func init() {
|
|
|
-// //AddComprehensiveIndustrialSource("Hz", 0)
|
|
|
-// AddComprehensiveRoadshow()
|
|
|
+//AddComprehensiveIndustrialSource("Hz", 0)
|
|
|
+//AddComprehensiveActivityVoice()
|
|
|
//}
|
|
|
|
|
|
// 添加文章:报告、纪要
|
|
@@ -404,7 +404,7 @@ func AddComprehensiveActivityVideo() {
|
|
|
//indexName := utils.IndexNameComprehensive
|
|
|
for _, v := range list {
|
|
|
item := new(ElasticComprehensiveDetail)
|
|
|
- item.SourceId = v.ActivityId
|
|
|
+ item.SourceId = v.Id
|
|
|
item.Source = "activityvideo"
|
|
|
item.Title = v.Title
|
|
|
item.PublishDate = v.ActivityTime
|
|
@@ -490,7 +490,7 @@ func AddComprehensiveActivityVoice() {
|
|
|
//indexName := utils.IndexNameComprehensive
|
|
|
for _, v := range list {
|
|
|
item := new(ElasticComprehensiveDetail)
|
|
|
- item.SourceId = v.ActivityId
|
|
|
+ item.SourceId = v.ActivityVoiceId
|
|
|
item.Source = "activityvoice"
|
|
|
item.Title = v.VoiceName
|
|
|
item.PublishDate = v.ActivityTime
|
|
@@ -634,235 +634,6 @@ func EsDeleteComprehensiveData(item *ElasticComprehensiveDetail) (err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//func EsComprehensiveSearch(keyWord string, startSize, pageSize int) (result []*SearchComprehensiveItem, total int64, err error) {
|
|
|
-// indexName := utils.IndexNameComprehensive
|
|
|
-// client := utils.Client
|
|
|
-// var keyWordArr []string
|
|
|
-// keyWordArr = append(keyWordArr, keyWord)
|
|
|
-//
|
|
|
-// //Es 的高级查询有 自定义排序 文档一时半会儿撸不懂,先做多次查询手动过滤 2023.2.2
|
|
|
-// //ikType 查询方式 ,0:查所有 、 1:查询键入词 、 2:查询除了查询键入词之外的联想词
|
|
|
-// mustMap := make([]interface{}, 0)
|
|
|
-// shouldMap := make(map[string]interface{}, 0)
|
|
|
-// shouldMapquery := make([]interface{}, 0)
|
|
|
-//
|
|
|
-// mustNotMap := make([]interface{}, 0)
|
|
|
-// shouldNotMap := make(map[string]interface{}, 0)
|
|
|
-// shouldNotMapquery := make([]interface{}, 0)
|
|
|
-// var boost int
|
|
|
-// //lenkeyWordArr := len(keyWordArr)
|
|
|
-// for k, v := range keyWordArr {
|
|
|
-// if k > 0 {
|
|
|
-// continue
|
|
|
-// }
|
|
|
-// if k == 0 {
|
|
|
-// boost = 2 * 1000
|
|
|
-// } else {
|
|
|
-// boost = 1
|
|
|
-// }
|
|
|
-//
|
|
|
-// if v != "" {
|
|
|
-// shouldMapquery = append(shouldMapquery, map[string]interface{}{
|
|
|
-// "function_score": map[string]interface{}{
|
|
|
-// "query": map[string]interface{}{
|
|
|
-// "multi_match": map[string]interface{}{
|
|
|
-// //"boost": (lenkeyWordArr - k) * boost, //给查询的值赋予权重
|
|
|
-// "boost": boost, //给查询的值赋予权重
|
|
|
-// "fields": []interface{}{"Title"},
|
|
|
-// "query": v,
|
|
|
-// },
|
|
|
-// },
|
|
|
-// },
|
|
|
-// })
|
|
|
-// shouldMapquery = append(shouldMapquery, map[string]interface{}{
|
|
|
-// "function_score": map[string]interface{}{
|
|
|
-// "query": map[string]interface{}{
|
|
|
-// "multi_match": map[string]interface{}{
|
|
|
-// "boost": boost, //给查询的值赋予权重
|
|
|
-// "fields": []interface{}{"Abstract"},
|
|
|
-// "query": v,
|
|
|
-// },
|
|
|
-// },
|
|
|
-// },
|
|
|
-// })
|
|
|
-// shouldMapquery = append(shouldMapquery, map[string]interface{}{
|
|
|
-// "function_score": map[string]interface{}{
|
|
|
-// "query": map[string]interface{}{
|
|
|
-// "multi_match": map[string]interface{}{
|
|
|
-// "boost": boost, //给查询的值赋予权重
|
|
|
-// "fields": []interface{}{"Annotation"},
|
|
|
-// "query": v,
|
|
|
-// },
|
|
|
-// },
|
|
|
-// },
|
|
|
-// })
|
|
|
-//
|
|
|
-// shouldMapquery = append(shouldMapquery, map[string]interface{}{
|
|
|
-// "function_score": map[string]interface{}{
|
|
|
-// "query": map[string]interface{}{
|
|
|
-// "multi_match": map[string]interface{}{
|
|
|
-// //"boost": (lenkeyWordArr-k)*boost - 1, //给查询的值赋予权重
|
|
|
-// "boost": boost, //给查询的值赋予权重
|
|
|
-// "fields": []interface{}{"BodyText"},
|
|
|
-// "query": v,
|
|
|
-// },
|
|
|
-// },
|
|
|
-// },
|
|
|
-// })
|
|
|
-//
|
|
|
-// shouldMapquery = append(shouldMapquery, map[string]interface{}{
|
|
|
-// "function_score": map[string]interface{}{
|
|
|
-// "query": map[string]interface{}{
|
|
|
-// "multi_match": map[string]interface{}{
|
|
|
-// //"boost": (lenkeyWordArr-k)*boost - 1, //给查询的值赋予权重
|
|
|
-// "boost": boost, //给查询的值赋予权重
|
|
|
-// "fields": []interface{}{"IndustryName"},
|
|
|
-// "query": v,
|
|
|
-// },
|
|
|
-// },
|
|
|
-// },
|
|
|
-// })
|
|
|
-//
|
|
|
-// shouldMapquery = append(shouldMapquery, map[string]interface{}{
|
|
|
-// "function_score": map[string]interface{}{
|
|
|
-// "query": map[string]interface{}{
|
|
|
-// "multi_match": map[string]interface{}{
|
|
|
-// //"boost": (lenkeyWordArr-k)*boost - 1, //给查询的值赋予权重
|
|
|
-// "boost": boost, //给查询的值赋予权重
|
|
|
-// "fields": []interface{}{"SubjectNames"},
|
|
|
-// "query": v,
|
|
|
-// },
|
|
|
-// },
|
|
|
-// },
|
|
|
-// })
|
|
|
-// }
|
|
|
-// }
|
|
|
-// shouldMap = map[string]interface{}{
|
|
|
-// "should": shouldMapquery,
|
|
|
-// }
|
|
|
-//
|
|
|
-// shouldNotMap = map[string]interface{}{
|
|
|
-// "should": shouldNotMapquery,
|
|
|
-// }
|
|
|
-// //排序
|
|
|
-// sortMap := make([]interface{}, 0)
|
|
|
-//
|
|
|
-// //时间
|
|
|
-// sortMap = append(sortMap, map[string]interface{}{
|
|
|
-// "PublishDate": map[string]interface{}{
|
|
|
-// "order": "desc",
|
|
|
-// },
|
|
|
-// })
|
|
|
-// //sortMap = append(sortMap, map[string]interface{}{
|
|
|
-// // "_score": map[string]interface{}{
|
|
|
-// // "order": "desc",
|
|
|
-// // },
|
|
|
-// //})
|
|
|
-// //高亮
|
|
|
-// highlightMap := make(map[string]interface{}, 0)
|
|
|
-// highlightMap = map[string]interface{}{
|
|
|
-// "fields": map[string]interface{}{
|
|
|
-// "BodyText": map[string]interface{}{},
|
|
|
-// "Title": map[string]interface{}{},
|
|
|
-// "Abstract": map[string]interface{}{},
|
|
|
-// "Annotation": map[string]interface{}{},
|
|
|
-// },
|
|
|
-// //样式 红色
|
|
|
-// "post_tags": []interface{}{"</font>"},
|
|
|
-// "pre_tags": []interface{}{"<font color='red'>"},
|
|
|
-// "fragment_size": 50,
|
|
|
-// }
|
|
|
-//
|
|
|
-// mustMap = append(mustMap, map[string]interface{}{
|
|
|
-// "bool": shouldMap,
|
|
|
-// })
|
|
|
-//
|
|
|
-// mustNotMap = append(mustNotMap, map[string]interface{}{
|
|
|
-// "term": shouldNotMap,
|
|
|
-// })
|
|
|
-// //mustMap = append(mustMap, map[string]interface{}{
|
|
|
-// // "term": map[string]interface{}{
|
|
|
-// // "IsSummary": "1",
|
|
|
-// // },
|
|
|
-// //})
|
|
|
-// queryMap := map[string]interface{}{
|
|
|
-// "query": map[string]interface{}{
|
|
|
-// "bool": map[string]interface{}{
|
|
|
-// "must": mustMap,
|
|
|
-// },
|
|
|
-// },
|
|
|
-// }
|
|
|
-//
|
|
|
-// queryMap["sort"] = sortMap
|
|
|
-// queryMap["from"] = startSize
|
|
|
-// queryMap["size"] = pageSize
|
|
|
-// queryMap["highlight"] = highlightMap
|
|
|
-// //jsonBytes, _ := json.Marshal(queryMap)
|
|
|
-// //fmt.Println(string(jsonBytes))
|
|
|
-// //utils.FileLog.Info(string(jsonBytes))
|
|
|
-// request := client.Search(indexName).Source(queryMap) // sets the JSON request
|
|
|
-// searchByMatch, err := request.Do(context.Background())
|
|
|
-// if searchByMatch != nil {
|
|
|
-// if searchByMatch.Hits != nil {
|
|
|
-// for _, v := range searchByMatch.Hits.Hits {
|
|
|
-// var isAppend bool
|
|
|
-// articleJson, err := v.Source.MarshalJSON()
|
|
|
-// if err != nil {
|
|
|
-// return nil, 0, err
|
|
|
-// }
|
|
|
-// article := new(ElasticComprehensiveDetail)
|
|
|
-// err = json.Unmarshal(articleJson, &article)
|
|
|
-// if err != nil {
|
|
|
-// return nil, 0, err
|
|
|
-// }
|
|
|
-// //fmt.Println(article.SourceId, article.Title, article.Source)
|
|
|
-// searchItem := new(SearchComprehensiveItem)
|
|
|
-// searchItem.SourceId = article.SourceId
|
|
|
-// if len(v.Highlight["Annotation"]) > 0 {
|
|
|
-// for _, vText := range v.Highlight["Annotation"] {
|
|
|
-// searchItem.Body = append(searchItem.Body, vText)
|
|
|
-// }
|
|
|
-// }
|
|
|
-// if len(v.Highlight["Abstract"]) > 0 {
|
|
|
-// for _, vText := range v.Highlight["Abstract"] {
|
|
|
-// searchItem.Body = append(searchItem.Body, vText)
|
|
|
-// }
|
|
|
-// }
|
|
|
-// if len(v.Highlight["BodyText"]) > 0 {
|
|
|
-// for _, vText := range v.Highlight["BodyText"] {
|
|
|
-// searchItem.Body = append(searchItem.Body, vText)
|
|
|
-// }
|
|
|
-// }
|
|
|
-// searchItem.IsSummary = article.IsSummary
|
|
|
-// if len(searchItem.Body) == 0 {
|
|
|
-// bodyRune := []rune(article.BodyText)
|
|
|
-// bodyRuneLen := len(bodyRune)
|
|
|
-// if bodyRuneLen > 100 {
|
|
|
-// bodyRuneLen = 100
|
|
|
-// }
|
|
|
-// body := string(bodyRune[:bodyRuneLen])
|
|
|
-// searchItem.Body = []string{body}
|
|
|
-// }
|
|
|
-// var title string
|
|
|
-// if len(v.Highlight["Title"]) > 0 {
|
|
|
-// title = v.Highlight["Title"][0]
|
|
|
-// } else {
|
|
|
-// title = article.Title
|
|
|
-// }
|
|
|
-// searchItem.Title = title
|
|
|
-// searchItem.Source = article.Source
|
|
|
-// searchItem.PublishDate = article.PublishDate
|
|
|
-//
|
|
|
-// if !isAppend {
|
|
|
-// result = append(result, searchItem)
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// total = searchByMatch.Hits.TotalHits.Value
|
|
|
-// }
|
|
|
-// return
|
|
|
-//}
|
|
|
-
|
|
|
func EsComprehensiveSearch(keyWord string, startSize, pageSize int) (result []*SearchComprehensiveItem, total int64, err error) {
|
|
|
indexName := utils.IndexNameComprehensive
|
|
|
client := utils.Client
|
|
@@ -1159,7 +930,7 @@ func GetResourceDataEsList(list []*SearchComprehensiveItem, user *models.WxUserI
|
|
|
} else if v.Source == "industrialsourceHz" {
|
|
|
industrialResourceIdsHz = append(industrialResourceIdsHz, v.SourceId)
|
|
|
} else if v.Source == "industrialResourceIdsYx" {
|
|
|
- industrialResourceIdsHz = append(industrialResourceIdsYx, v.SourceId)
|
|
|
+ industrialResourceIdsYx = append(industrialResourceIdsYx, v.SourceId)
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -1352,7 +1123,7 @@ func GetResourceDataEsList(list []*SearchComprehensiveItem, user *models.WxUserI
|
|
|
industrialResourceIdstring = append(industrialResourceIdstring, strconv.Itoa(v))
|
|
|
}
|
|
|
industrialId := strings.Join(industrialResourceIdstring, ",")
|
|
|
- condition = ` AND m.industrial_management_id IN (` + industrialId + `) AND a.article_type = 0 `
|
|
|
+ condition = ` AND m.industrial_management_id IN (` + industrialId + `) AND a.article_type_id = 0 `
|
|
|
listIndustrialResourceIds, e := models.GetSearchResourceList(user.UserId, condition, 0, len(industrialResourceIdsHz))
|
|
|
if e != nil {
|
|
|
err = errors.New("GetSearchResourceList, Err: " + e.Error())
|
|
@@ -1386,7 +1157,7 @@ func GetResourceDataEsList(list []*SearchComprehensiveItem, user *models.WxUserI
|
|
|
industrialResourceIdstring = append(industrialResourceIdstring, strconv.Itoa(v))
|
|
|
}
|
|
|
industrialId := strings.Join(industrialResourceIdstring, ",")
|
|
|
- condition = ` AND m.industrial_management_id IN (` + industrialId + `) AND a.article_type > 0 `
|
|
|
+ condition = ` AND m.industrial_management_id IN (` + industrialId + `) AND a.article_type_id > 0 `
|
|
|
listIndustrialResourceIds, e := models.GetSearchResourceList(user.UserId, condition, 0, len(industrialResourceIdsYx))
|
|
|
if e != nil {
|
|
|
err = errors.New("GetSearchResourceList, Err: " + e.Error())
|