|
@@ -72,6 +72,11 @@ var topType = map[string]string{
|
|
|
"采购意向": "采购意向",
|
|
|
}
|
|
|
|
|
|
+//包含正文或 附件 不包含标题
|
|
|
+func DetailFileORTitle(findfields string) bool {
|
|
|
+ return (strings.Contains(findfields, "detail") || strings.Contains(findfields, "filetext")) && !strings.Contains(findfields, "title")
|
|
|
+}
|
|
|
+
|
|
|
//获取数据导出查询语句
|
|
|
func getDataExportSql(scd *SieveCondition) string {
|
|
|
if len(scd.SelectIds) > 0 {
|
|
@@ -237,7 +242,7 @@ func getDataExportSql(scd *SieveCondition) string {
|
|
|
} else {
|
|
|
queryItem = strings.ReplaceAll(scd.SelectType, ",", "\",\"")
|
|
|
}
|
|
|
- multi_match = fmt.Sprintf(multi_match, "%s", "\""+queryItem+"\"")
|
|
|
+ multi_match_new := fmt.Sprintf(multi_match, "%s", "\""+queryItem+"\"")
|
|
|
|
|
|
if scd.Comeinfrom == "supersearchPage" {
|
|
|
var keywordArr []string
|
|
@@ -261,33 +266,53 @@ func getDataExportSql(scd *SieveCondition) string {
|
|
|
if v.Keyword != "" {
|
|
|
if strings.Contains(v.Keyword, "+") {
|
|
|
for _, vk := range strings.Split(v.Keyword, "+") {
|
|
|
- //多个关键词 单个字 正文搜索 排除
|
|
|
- if scd.SelectType == "detail" && len(strings.Split(v.Keyword, "+")) > 1 && len([]rune(elastic.ReplaceYH(vk))) == 1 {
|
|
|
- continue
|
|
|
+ //单个字 搜索范围 有全文或者附件 无标题 例如:学 虚拟机 detail 搜索的时候加上标题
|
|
|
+ if scd.Comeinfrom == "supersearchPage" && DetailFileORTitle(scd.SelectType) && len([]rune(elastic.ReplaceYH(vk))) == 1 {
|
|
|
+ queryItem = strings.ReplaceAll(scd.SelectType+"title", ",", "\",\"")
|
|
|
+ shouldsKey := fmt.Sprintf(multi_match, "\""+vk+"\"", "\""+queryItem+"\"")
|
|
|
+ shoulds = append(shoulds, shouldsKey)
|
|
|
+ } else {
|
|
|
+ shoulds = append(shoulds, fmt.Sprintf(multi_match_new, "\""+vk+"\""))
|
|
|
}
|
|
|
- shoulds = append(shoulds, fmt.Sprintf(multi_match, "\""+vk+"\""))
|
|
|
}
|
|
|
} else if strings.Contains(v.Keyword, " ") {
|
|
|
for _, vk := range strings.Split(v.Keyword, " ") {
|
|
|
- //多个关键词 单个字 正文搜索 排除
|
|
|
- if scd.SelectType == "detail" && len(strings.Split(v.Keyword, " ")) > 1 && len([]rune(elastic.ReplaceYH(vk))) == 1 {
|
|
|
- continue
|
|
|
+ //单个字 搜索范围 有全文或者附件 无标题 例如:学 虚拟机 detail 搜索的时候加上标题
|
|
|
+ if scd.Comeinfrom == "supersearchPage" && DetailFileORTitle(scd.SelectType) && len([]rune(elastic.ReplaceYH(vk))) == 1 {
|
|
|
+ queryItem = strings.ReplaceAll(scd.SelectType+"title", ",", "\",\"")
|
|
|
+ shouldsKey := fmt.Sprintf(multi_match, "\""+vk+"\"", "\""+queryItem+"\"")
|
|
|
+ shoulds = append(shoulds, shouldsKey)
|
|
|
+ } else {
|
|
|
+ shoulds = append(shoulds, fmt.Sprintf(multi_match_new, "\""+vk+"\""))
|
|
|
}
|
|
|
- shoulds = append(shoulds, fmt.Sprintf(multi_match, "\""+vk+"\""))
|
|
|
}
|
|
|
} else {
|
|
|
- shoulds = append(shoulds, fmt.Sprintf(multi_match, "\""+v.Keyword+"\""))
|
|
|
+ //单个字 搜索范围 有全文或者附件 无标题 例如:学 虚拟机 detail 搜索的时候加上标题
|
|
|
+ if scd.Comeinfrom == "supersearchPage" && DetailFileORTitle(scd.SelectType) && len([]rune(elastic.ReplaceYH(v.Keyword))) == 1 {
|
|
|
+ queryItem = strings.ReplaceAll(scd.SelectType+"title", ",", "\",\"")
|
|
|
+ shouldsKey := fmt.Sprintf(multi_match, "\""+v.Keyword+"\"", "\""+queryItem+"\"")
|
|
|
+ shoulds = append(shoulds, shouldsKey)
|
|
|
+ } else {
|
|
|
+ shoulds = append(shoulds, fmt.Sprintf(multi_match_new, "\""+v.Keyword+"\""))
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//附加词
|
|
|
for _, vv := range v.Appended {
|
|
|
- shoulds = append(shoulds, fmt.Sprintf(multi_match, "\""+vv+"\""))
|
|
|
+ shoulds = append(shoulds, fmt.Sprintf(multi_match_new, "\""+vv+"\""))
|
|
|
}
|
|
|
|
|
|
//排除词
|
|
|
for _, vv := range v.Exclude {
|
|
|
- must_not = append(must_not, fmt.Sprintf(multi_match, "\""+vv+"\""))
|
|
|
+ //单个字 搜索范围 有全文或者附件 无标题 例如:学 虚拟机 detail 搜索的时候加上标题
|
|
|
+ if scd.Comeinfrom == "supersearchPage" && DetailFileORTitle(scd.SelectType) && len([]rune(elastic.ReplaceYH(vv))) == 1 {
|
|
|
+ queryItem = strings.ReplaceAll(scd.SelectType+"title", ",", "\",\"")
|
|
|
+ shouldsKey := fmt.Sprintf(multi_match, "\""+vv+"\"", "\""+queryItem+"\"")
|
|
|
+ shoulds = append(shoulds, shouldsKey)
|
|
|
+ } else {
|
|
|
+ must_not = append(must_not, fmt.Sprintf(multi_match_new, "\""+vv+"\""))
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//添加
|