|
@@ -109,12 +109,32 @@ func EsAddOrEditEdbInfoData(indexName, docId string, item *data_manage.EdbInfoLi
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-func SearchEdbInfoData(indexName, keywordStr string, from, size, filterSource, source int, edbInfoType int8, frequency string, noPermissionEdbInfoIdList, noPermissionEdbClassifyIdList []int, edbType int) (total int64, list []*data_manage.EdbInfoList, err error) {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+func SearchEdbInfoData(keywordStr string, from, size, filterSource, source int, frequency string, noPermissionEdbInfoIdList, noPermissionEdbClassifyIdList, collectEdbInfoIdList, edbTypeList []int, edbInfoType, edbAuth, sysUserId int) (total int64, list []*data_manage.EdbInfoList, err error) {
|
|
|
+ indexName := utils.DATA_INDEX_NAME
|
|
|
list = make([]*data_manage.EdbInfoList, 0)
|
|
|
defer func() {
|
|
|
if err != nil {
|
|
|
- fmt.Println("EsAddOrEditData Err:", err.Error())
|
|
|
+ fmt.Println("SearchEdbInfoData Err:", err.Error())
|
|
|
}
|
|
|
}()
|
|
|
|
|
@@ -122,649 +142,55 @@ func SearchEdbInfoData(indexName, keywordStr string, from, size, filterSource, s
|
|
|
highlight = highlight.Fields(elastic.NewHighlighterField("EdbCode"), elastic.NewHighlighterField("EdbName"))
|
|
|
highlight = highlight.PreTags("<font color='red'>").PostTags("</font>")
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
mustMap := make([]interface{}, 0)
|
|
|
mustNotMap := make([]interface{}, 0)
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
switch filterSource {
|
|
|
case 2:
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- mustMap = []interface{}{
|
|
|
- map[string]interface{}{
|
|
|
- "term": map[string]interface{}{
|
|
|
- "Frequency.keyword": "月度",
|
|
|
-
|
|
|
- },
|
|
|
- },
|
|
|
- }
|
|
|
- case 3:
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- case 4:
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- mustMap = []interface{}{
|
|
|
- map[string]interface{}{
|
|
|
- "term": map[string]interface{}{
|
|
|
- "EdbType": 1,
|
|
|
- },
|
|
|
- },
|
|
|
- }
|
|
|
- case 5:
|
|
|
- mustMap = []interface{}{
|
|
|
- map[string]interface{}{
|
|
|
- "term": map[string]interface{}{
|
|
|
- "Source": 6,
|
|
|
- },
|
|
|
- },
|
|
|
- }
|
|
|
- case 6:
|
|
|
- mustNotMap = []interface{}{
|
|
|
- map[string]interface{}{
|
|
|
- "match": map[string]interface{}{
|
|
|
- "Frequency.keyword": "年度",
|
|
|
- },
|
|
|
- },
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if source > 0 {
|
|
|
mustMap = append(mustMap, map[string]interface{}{
|
|
|
"term": map[string]interface{}{
|
|
|
- "Source": source,
|
|
|
+ "Frequency.keyword": "月度",
|
|
|
|
|
|
},
|
|
|
})
|
|
|
- }
|
|
|
-
|
|
|
- if frequency != "" {
|
|
|
- mustMap = append(mustMap, map[string]interface{}{
|
|
|
- "term": map[string]interface{}{
|
|
|
- "Frequency.keyword": frequency,
|
|
|
-
|
|
|
- },
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if len(noPermissionEdbInfoIdList) > 0 {
|
|
|
- mustNotMap = append(mustNotMap, map[string]interface{}{
|
|
|
- "terms": map[string]interface{}{
|
|
|
- "EdbInfoId": noPermissionEdbInfoIdList,
|
|
|
-
|
|
|
- },
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if len(noPermissionEdbClassifyIdList) > 0 {
|
|
|
- mustNotMap = append(mustNotMap, map[string]interface{}{
|
|
|
- "terms": map[string]interface{}{
|
|
|
- "ClassifyId": noPermissionEdbClassifyIdList,
|
|
|
-
|
|
|
- },
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if edbInfoType >= 0 {
|
|
|
- mustMap = append(mustMap, map[string]interface{}{
|
|
|
- "term": map[string]interface{}{
|
|
|
- "EdbInfoType": edbInfoType,
|
|
|
- },
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if edbType > 0 {
|
|
|
- mustMap = append(mustMap, map[string]interface{}{
|
|
|
- "term": map[string]interface{}{
|
|
|
- "EdbType": edbType,
|
|
|
- },
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- keywordNameKey := `EdbName`
|
|
|
-
|
|
|
- if !utils.ContainsChinese(keywordStr) {
|
|
|
- keywordNameKey = `EdbNameEn`
|
|
|
- }
|
|
|
- shouldMap := map[string]interface{}{
|
|
|
- "should": []interface{}{
|
|
|
- map[string]interface{}{
|
|
|
- "match": map[string]interface{}{
|
|
|
- "EdbCode": keywordStr,
|
|
|
-
|
|
|
- },
|
|
|
- },
|
|
|
- map[string]interface{}{
|
|
|
- "match": map[string]interface{}{
|
|
|
- keywordNameKey: keywordStr,
|
|
|
-
|
|
|
- },
|
|
|
- },
|
|
|
- },
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- return searchEdbInfoData(indexName, mustMap, mustNotMap, shouldMap, from, size)
|
|
|
-}
|
|
|
-
|
|
|
-func SearchEdbInfoDataBak(indexName, keywordStr string, from, size, filterSource, source int, frequency string) (total int64, list []*data_manage.EdbInfoList, err error) {
|
|
|
- list = make([]*data_manage.EdbInfoList, 0)
|
|
|
- defer func() {
|
|
|
- if err != nil {
|
|
|
- fmt.Println("EsAddOrEditData Err:", err.Error())
|
|
|
- }
|
|
|
-
|
|
|
- for _, v := range list {
|
|
|
- v.ConvertToResp()
|
|
|
- }
|
|
|
- }()
|
|
|
- client := utils.EsClient
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- highlight := elastic.NewHighlight()
|
|
|
- highlight = highlight.Fields(elastic.NewHighlighterField("EdbCode"), elastic.NewHighlighterField("EdbName"))
|
|
|
- highlight = highlight.PreTags("<font color='red'>").PostTags("</font>")
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- mustMap := make([]interface{}, 0)
|
|
|
- mustNotMap := make([]interface{}, 0)
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- switch filterSource {
|
|
|
- case 2:
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- mustMap = []interface{}{
|
|
|
- map[string]interface{}{
|
|
|
- "term": map[string]interface{}{
|
|
|
- "Frequency.keyword": "月度",
|
|
|
-
|
|
|
- },
|
|
|
- },
|
|
|
- }
|
|
|
case 3:
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
case 4:
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- mustMap = []interface{}{
|
|
|
- map[string]interface{}{
|
|
|
- "term": map[string]interface{}{
|
|
|
- "EdbType": 1,
|
|
|
- },
|
|
|
- },
|
|
|
- }
|
|
|
- case 5:
|
|
|
- mustMap = []interface{}{
|
|
|
- map[string]interface{}{
|
|
|
- "term": map[string]interface{}{
|
|
|
- "Source": 6,
|
|
|
- },
|
|
|
- },
|
|
|
- }
|
|
|
- case 6:
|
|
|
- mustNotMap = []interface{}{
|
|
|
- map[string]interface{}{
|
|
|
- "match": map[string]interface{}{
|
|
|
- "Frequency.keyword": "年度",
|
|
|
- },
|
|
|
- },
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if source > 0 {
|
|
|
- mustMap = append(mustMap, map[string]interface{}{
|
|
|
- "term": map[string]interface{}{
|
|
|
- "Source": source,
|
|
|
-
|
|
|
- },
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
- if frequency != "" {
|
|
|
mustMap = append(mustMap, map[string]interface{}{
|
|
|
"term": map[string]interface{}{
|
|
|
- "Frequency.keyword": frequency,
|
|
|
-
|
|
|
- },
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- shouldMap := map[string]interface{}{
|
|
|
- "should": []interface{}{
|
|
|
- map[string]interface{}{
|
|
|
- "match": map[string]interface{}{
|
|
|
- "EdbCode": keywordStr,
|
|
|
-
|
|
|
- },
|
|
|
- },
|
|
|
- map[string]interface{}{
|
|
|
- "match": map[string]interface{}{
|
|
|
- "EdbName": keywordStr,
|
|
|
-
|
|
|
- },
|
|
|
- },
|
|
|
-
|
|
|
-
|
|
|
- map[string]interface{}{
|
|
|
- "match": map[string]interface{}{
|
|
|
- "EdbCode": map[string]interface{}{
|
|
|
- "query": keywordStr,
|
|
|
- "operator": "and",
|
|
|
- },
|
|
|
-
|
|
|
- },
|
|
|
- },
|
|
|
-
|
|
|
-
|
|
|
- map[string]interface{}{
|
|
|
- "match": map[string]interface{}{
|
|
|
- "EdbName": map[string]interface{}{
|
|
|
- "query": keywordStr,
|
|
|
- "operator": "and",
|
|
|
- },
|
|
|
-
|
|
|
- },
|
|
|
- },
|
|
|
- },
|
|
|
- }
|
|
|
- mustMap = append(mustMap, map[string]interface{}{
|
|
|
- "bool": shouldMap,
|
|
|
- })
|
|
|
-
|
|
|
- queryMap := map[string]interface{}{
|
|
|
- "query": map[string]interface{}{
|
|
|
- "bool": map[string]interface{}{
|
|
|
- "must": mustMap,
|
|
|
- "must_not": mustNotMap,
|
|
|
-
|
|
|
- },
|
|
|
- },
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- requestTotalHits := client.Count(indexName).BodyJson(queryMap)
|
|
|
- total, err = requestTotalHits.Do(context.Background())
|
|
|
- if err != nil {
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- queryMap["from"] = from
|
|
|
- queryMap["size"] = size
|
|
|
- jsonBytes, _ := json.Marshal(queryMap)
|
|
|
- fmt.Println(string(jsonBytes))
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- request := client.Search(indexName).Highlight(highlight).Source(queryMap)
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- searchMap := make(map[string]string)
|
|
|
-
|
|
|
- searchResp, err := request.Do(context.Background())
|
|
|
- if err != nil {
|
|
|
- return
|
|
|
- }
|
|
|
- fmt.Println(searchResp)
|
|
|
- fmt.Println(searchResp.Status)
|
|
|
- if searchResp.Status != 0 {
|
|
|
- return
|
|
|
- }
|
|
|
- if searchResp.Hits != nil {
|
|
|
- for _, v := range searchResp.Hits.Hits {
|
|
|
- if _, ok := searchMap[v.Id]; !ok {
|
|
|
- itemJson, tmpErr := v.Source.MarshalJSON()
|
|
|
- if tmpErr != nil {
|
|
|
- err = tmpErr
|
|
|
- fmt.Println("movieJson err:", err)
|
|
|
- return
|
|
|
- }
|
|
|
- edbInfoItem := new(data_manage.EdbInfoList)
|
|
|
- tmpErr = json.Unmarshal(itemJson, &edbInfoItem)
|
|
|
- if tmpErr != nil {
|
|
|
- fmt.Println("json.Unmarshal movieJson err:", tmpErr)
|
|
|
- err = tmpErr
|
|
|
- return
|
|
|
- }
|
|
|
- if len(v.Highlight["EdbCode"]) > 0 {
|
|
|
- edbInfoItem.EdbCode = v.Highlight["EdbCode"][0]
|
|
|
- }
|
|
|
- if len(v.Highlight["EdbName"]) > 0 {
|
|
|
- edbInfoItem.EdbCode = v.Highlight["EdbName"][0]
|
|
|
- }
|
|
|
- list = append(list, edbInfoItem)
|
|
|
- searchMap[v.Id] = v.Id
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-func SearchAddPredictEdbInfoData(indexName, keywordStr string, noPermissionEdbInfoIdList, noPermissionEdbClassifyIdList []int, from, size, edbType int) (total int64, list []*data_manage.EdbInfoList, err error) {
|
|
|
- list = make([]*data_manage.EdbInfoList, 0)
|
|
|
- defer func() {
|
|
|
- if err != nil {
|
|
|
- fmt.Println("EsAddOrEditData Err:", err.Error())
|
|
|
- }
|
|
|
-
|
|
|
- for _, v := range list {
|
|
|
- v.ConvertToResp()
|
|
|
- }
|
|
|
- }()
|
|
|
-
|
|
|
- highlight := elastic.NewHighlight()
|
|
|
- highlight = highlight.Fields(elastic.NewHighlighterField("EdbCode"), elastic.NewHighlighterField("EdbName"))
|
|
|
- highlight = highlight.PreTags("<font color='red'>").PostTags("</font>")
|
|
|
-
|
|
|
- mustMap := make([]interface{}, 0)
|
|
|
- mustNotMap := make([]interface{}, 0)
|
|
|
-
|
|
|
- mustNotMap = []interface{}{
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ "EdbType": 1,
|
|
|
+ },
|
|
|
+ })
|
|
|
+ case 5:
|
|
|
+ mustMap = append(mustMap, map[string]interface{}{
|
|
|
+ "term": map[string]interface{}{
|
|
|
+ "Source": 6,
|
|
|
+ },
|
|
|
+ })
|
|
|
+ case 6:
|
|
|
+ mustMap = append(mustMap, map[string]interface{}{
|
|
|
+ "match": map[string]interface{}{
|
|
|
+ "Frequency.keyword": "年度",
|
|
|
+ },
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- mustMap = append(mustMap, map[string]interface{}{
|
|
|
- "term": map[string]interface{}{
|
|
|
- "EdbInfoType": 0,
|
|
|
- },
|
|
|
- })
|
|
|
- mustMap = append(mustMap, map[string]interface{}{
|
|
|
- "terms": map[string]interface{}{
|
|
|
- "Frequency.keyword": []string{"日度", "周度", "月度"},
|
|
|
- },
|
|
|
- })
|
|
|
-
|
|
|
-
|
|
|
- if edbType > 0 {
|
|
|
+
|
|
|
+ if source > 0 {
|
|
|
mustMap = append(mustMap, map[string]interface{}{
|
|
|
"term": map[string]interface{}{
|
|
|
- "EdbType": edbType,
|
|
|
+ "Source": source,
|
|
|
+
|
|
|
},
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- keywordNameKey := `EdbName`
|
|
|
-
|
|
|
- if !utils.ContainsChinese(keywordStr) {
|
|
|
- keywordNameKey = `EdbNameEn`
|
|
|
- }
|
|
|
- shouldMap := map[string]interface{}{
|
|
|
- "should": []interface{}{
|
|
|
- map[string]interface{}{
|
|
|
- "match": map[string]interface{}{
|
|
|
- "EdbCode": keywordStr,
|
|
|
-
|
|
|
- },
|
|
|
- },
|
|
|
- map[string]interface{}{
|
|
|
- "match": map[string]interface{}{
|
|
|
- keywordNameKey: keywordStr,
|
|
|
-
|
|
|
- },
|
|
|
+ if frequency != "" {
|
|
|
+ mustMap = append(mustMap, map[string]interface{}{
|
|
|
+ "term": map[string]interface{}{
|
|
|
+ "Frequency.keyword": frequency,
|
|
|
+
|
|
|
},
|
|
|
- },
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
|
|
@@ -777,7 +203,7 @@ func SearchAddPredictEdbInfoData(indexName, keywordStr string, noPermissionEdbIn
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
if len(noPermissionEdbClassifyIdList) > 0 {
|
|
|
mustNotMap = append(mustNotMap, map[string]interface{}{
|
|
|
"terms": map[string]interface{}{
|
|
@@ -787,11 +213,127 @@ func SearchAddPredictEdbInfoData(indexName, keywordStr string, noPermissionEdbIn
|
|
|
})
|
|
|
}
|
|
|
|
|
|
- return searchEdbInfoData(indexName, mustMap, mustNotMap, shouldMap, from, size)
|
|
|
+
|
|
|
+ if len(collectEdbInfoIdList) > 0 {
|
|
|
+ mustMap = append(mustMap, map[string]interface{}{
|
|
|
+ "terms": map[string]interface{}{
|
|
|
+ "EdbInfoId": collectEdbInfoIdList,
|
|
|
+ },
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if len(edbTypeList) > 0 {
|
|
|
+ mustMap = append(mustMap, map[string]interface{}{
|
|
|
+ "terms": map[string]interface{}{
|
|
|
+ "EdbType": edbTypeList,
|
|
|
+ },
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ if edbInfoType >= 0 {
|
|
|
+ mustMap = append(mustMap, map[string]interface{}{
|
|
|
+ "term": map[string]interface{}{
|
|
|
+ "EdbInfoType": edbInfoType,
|
|
|
+ },
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ shouldMapList := make([]map[string]interface{}, 0)
|
|
|
+
|
|
|
+
|
|
|
+ if keywordStr != `` {
|
|
|
+
|
|
|
+ keywordNameKey := `EdbName`
|
|
|
+ shouldMap := map[string]interface{}{
|
|
|
+ "should": []interface{}{
|
|
|
+ map[string]interface{}{
|
|
|
+ "match": map[string]interface{}{
|
|
|
+ "EdbCode": keywordStr,
|
|
|
+
|
|
|
+ },
|
|
|
+ },
|
|
|
+ map[string]interface{}{
|
|
|
+ "match": map[string]interface{}{
|
|
|
+ keywordNameKey: keywordStr,
|
|
|
+
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ }
|
|
|
+ shouldMapList = append(shouldMapList, shouldMap)
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ {
|
|
|
+ shouldTermList := make([]map[string]interface{}, 0)
|
|
|
+
|
|
|
+ switch edbAuth {
|
|
|
+ case 1:
|
|
|
+
|
|
|
+ shouldTermList = append(shouldTermList, map[string]interface{}{
|
|
|
+ "term": map[string]interface{}{
|
|
|
+ "SysUserId": sysUserId,
|
|
|
+ },
|
|
|
+ })
|
|
|
+ case 2:
|
|
|
+
|
|
|
+ shouldTermList = append(shouldTermList, map[string]interface{}{
|
|
|
+ "term": map[string]interface{}{
|
|
|
+ "PublicStatus": 3,
|
|
|
+ },
|
|
|
+ })
|
|
|
+ default:
|
|
|
+
|
|
|
+ shouldTermList = append(shouldTermList, map[string]interface{}{
|
|
|
+ "term": map[string]interface{}{
|
|
|
+ "SysUserId": sysUserId,
|
|
|
+ },
|
|
|
+ })
|
|
|
+
|
|
|
+ shouldTermList = append(shouldTermList, map[string]interface{}{
|
|
|
+ "terms": map[string]interface{}{
|
|
|
+ "SharedUserIdList": []int{sysUserId},
|
|
|
+ },
|
|
|
+ })
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ shouldMap := map[string]interface{}{
|
|
|
+ "should": shouldTermList,
|
|
|
+ }
|
|
|
+ shouldMapList = append(shouldMapList, shouldMap)
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ sortList := make([]interface{}, 0)
|
|
|
+
|
|
|
+ if keywordStr == `` {
|
|
|
+ sortEdbInfoId := map[string]interface{}{
|
|
|
+ "EdbInfoId": map[string]interface{}{
|
|
|
+ "order": "desc",
|
|
|
+ },
|
|
|
+ }
|
|
|
+ sortList = append(sortList, sortEdbInfoId)
|
|
|
+ }
|
|
|
+
|
|
|
+ return searchEdbInfoData(indexName, mustMap, mustNotMap, shouldMapList, sortList, from, size)
|
|
|
}
|
|
|
|
|
|
|
|
|
-func searchEdbInfoData(indexName string, mustMap, mustNotMap []interface{}, shouldMap map[string]interface{}, from, size int) (total int64, list []*data_manage.EdbInfoList, err error) {
|
|
|
+func searchEdbInfoData(indexName string, mustMap, mustNotMap []interface{}, shouldMapList []map[string]interface{}, sortList []interface{}, from, size int) (total int64, list []*data_manage.EdbInfoList, err error) {
|
|
|
list = make([]*data_manage.EdbInfoList, 0)
|
|
|
defer func() {
|
|
|
if err != nil {
|
|
@@ -815,9 +357,11 @@ func searchEdbInfoData(indexName string, mustMap, mustNotMap []interface{}, shou
|
|
|
|
|
|
|
|
|
|
|
|
- mustMap = append(mustMap, map[string]interface{}{
|
|
|
- "bool": shouldMap,
|
|
|
- })
|
|
|
+ for _, shouldMap := range shouldMapList {
|
|
|
+ mustMap = append(mustMap, map[string]interface{}{
|
|
|
+ "bool": shouldMap,
|
|
|
+ })
|
|
|
+ }
|
|
|
|
|
|
queryMap := map[string]interface{}{
|
|
|
"query": map[string]interface{}{
|
|
@@ -838,21 +382,15 @@ func searchEdbInfoData(indexName string, mustMap, mustNotMap []interface{}, shou
|
|
|
|
|
|
queryMap["from"] = from
|
|
|
queryMap["size"] = size
|
|
|
+
|
|
|
+
|
|
|
+ if len(sortList) > 0 {
|
|
|
+ queryMap["sort"] = sortList
|
|
|
+ }
|
|
|
+
|
|
|
jsonBytes, _ := json.Marshal(queryMap)
|
|
|
fmt.Println(string(jsonBytes))
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
|
|
|
|
|
|
|
|
@@ -1484,230 +1022,3 @@ func SearchMyChartInfoData(indexName, keywordStr string, adminId int, noPermissi
|
|
|
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-func SearchEdbInfoDataByAdminId(indexName, keywordStr string, from, size, filterSource, source int, edbInfoType uint8, frequency string, adminId int) (total int64, list []*data_manage.EdbInfoList, err error) {
|
|
|
- list = make([]*data_manage.EdbInfoList, 0)
|
|
|
- defer func() {
|
|
|
- if err != nil {
|
|
|
- fmt.Println("EsAddOrEditData Err:", err.Error())
|
|
|
- }
|
|
|
- for _, v := range list {
|
|
|
- v.ConvertToResp()
|
|
|
- }
|
|
|
- }()
|
|
|
-
|
|
|
- highlight := elastic.NewHighlight()
|
|
|
- highlight = highlight.Fields(elastic.NewHighlighterField("EdbCode"), elastic.NewHighlighterField("EdbName"))
|
|
|
- highlight = highlight.PreTags("<font color='red'>").PostTags("</font>")
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- mustMap := make([]interface{}, 0)
|
|
|
- mustNotMap := make([]interface{}, 0)
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- switch filterSource {
|
|
|
- case 2:
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- mustMap = []interface{}{
|
|
|
- map[string]interface{}{
|
|
|
- "term": map[string]interface{}{
|
|
|
- "Frequency.keyword": "月度",
|
|
|
-
|
|
|
- },
|
|
|
- },
|
|
|
- }
|
|
|
- case 3:
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- case 4:
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- mustMap = []interface{}{
|
|
|
- map[string]interface{}{
|
|
|
- "term": map[string]interface{}{
|
|
|
- "EdbType": 1,
|
|
|
- },
|
|
|
- },
|
|
|
- }
|
|
|
- case 5:
|
|
|
- mustMap = []interface{}{
|
|
|
- map[string]interface{}{
|
|
|
- "term": map[string]interface{}{
|
|
|
- "Source": 6,
|
|
|
- },
|
|
|
- },
|
|
|
- }
|
|
|
- case 6:
|
|
|
- mustNotMap = []interface{}{
|
|
|
- map[string]interface{}{
|
|
|
- "match": map[string]interface{}{
|
|
|
- "Frequency.keyword": "年度",
|
|
|
- },
|
|
|
- },
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if source > 0 {
|
|
|
- mustMap = append(mustMap, map[string]interface{}{
|
|
|
- "term": map[string]interface{}{
|
|
|
- "Source": source,
|
|
|
-
|
|
|
- },
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
- if frequency != "" {
|
|
|
- mustMap = append(mustMap, map[string]interface{}{
|
|
|
- "term": map[string]interface{}{
|
|
|
- "Frequency.keyword": frequency,
|
|
|
-
|
|
|
- },
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- mustMap = append(mustMap, map[string]interface{}{
|
|
|
- "term": map[string]interface{}{
|
|
|
- "EdbInfoType": edbInfoType,
|
|
|
- },
|
|
|
- })
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- keywordNameKey := `EdbName`
|
|
|
-
|
|
|
- if !utils.ContainsChinese(keywordStr) {
|
|
|
- keywordNameKey = `EdbNameEn`
|
|
|
- }
|
|
|
- shouldMap := map[string]interface{}{
|
|
|
- "should": []interface{}{
|
|
|
- map[string]interface{}{
|
|
|
- "match": map[string]interface{}{
|
|
|
- "EdbCode": keywordStr,
|
|
|
-
|
|
|
- },
|
|
|
- },
|
|
|
- map[string]interface{}{
|
|
|
- "match": map[string]interface{}{
|
|
|
- keywordNameKey: keywordStr,
|
|
|
-
|
|
|
- },
|
|
|
- },
|
|
|
- },
|
|
|
- }
|
|
|
-
|
|
|
- mustMap = append(mustMap, map[string]interface{}{
|
|
|
- "bool": shouldMap,
|
|
|
- })
|
|
|
-
|
|
|
-
|
|
|
- if adminId > 0 {
|
|
|
- mustMap = append(mustMap, map[string]interface{}{
|
|
|
- "term": map[string]interface{}{
|
|
|
- "SysUserId": adminId,
|
|
|
- },
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
- return searchEdbInfoData(indexName, mustMap, mustNotMap, shouldMap, from, size)
|
|
|
-}
|