Browse Source

wip:搜索导出空格分词后过滤空字符串

fuwencai 2 years ago
parent
commit
0cd7063281
1 changed files with 16 additions and 0 deletions
  1. 16 0
      src/jfw/modules/common/src/qfw/util/dataexport/dataexport.go

+ 16 - 0
src/jfw/modules/common/src/qfw/util/dataexport/dataexport.go

@@ -307,6 +307,9 @@ func getDataExportSql(scd *SieveCondition) string {
 			if v.Keyword != "" {
 				if strings.Contains(v.Keyword, "+") {
 					for _, vk := range strings.Split(v.Keyword, "+") {
+						if len(vk) == 0 {
+							continue
+						}
 						//单个字 搜索范围 有全文或者附件 无标题 例如:学 虚拟机 detail  搜索的时候加上标题
 						if scd.Comeinfrom == "supersearchPage" && DetailFileORTitle(selectType) && len([]rune(elastic.ReplaceYH(vk))) == 1 {
 							queryItem = strings.ReplaceAll(selectType+",title", ",", "\",\"")
@@ -318,6 +321,9 @@ func getDataExportSql(scd *SieveCondition) string {
 					}
 				} else if strings.Contains(v.Keyword, " ") {
 					for _, vk := range strings.Split(v.Keyword, " ") {
+						if len(vk) == 0 {
+							continue
+						}
 						//单个字 搜索范围 有全文或者附件 无标题 例如:学 虚拟机 detail  搜索的时候加上标题
 						if scd.Comeinfrom == "supersearchPage" && DetailFileORTitle(selectType) && len([]rune(elastic.ReplaceYH(vk))) == 1 {
 							queryItem = strings.ReplaceAll(selectType+",title", ",", "\",\"")
@@ -348,6 +354,9 @@ func getDataExportSql(scd *SieveCondition) string {
 					// 附加词处理分词
 					if strings.Contains(vv, "+") {
 						for _, vk := range strings.Split(vv, "+") {
+							if len(vk) == 0 {
+								continue
+							}
 							//单个字 搜索范围 有全文或者附件 无标题 例如:学 虚拟机 detail  搜索的时候加上标题
 							if scd.Comeinfrom == "supersearchPage" && DetailFileORTitle(selectType) && len([]rune(elastic.ReplaceYH(vk))) == 1 {
 								queryItem = strings.ReplaceAll(selectType+",title", ",", "\",\"")
@@ -359,6 +368,10 @@ func getDataExportSql(scd *SieveCondition) string {
 						}
 					} else if strings.Contains(vv, " ") {
 						for _, vk := range strings.Split(vv, " ") {
+							if len(vk) == 0 {
+								continue
+							}
+
 							//单个字 搜索范围 有全文或者附件 无标题 例如:学 虚拟机 detail  搜索的时候加上标题
 							if scd.Comeinfrom == "supersearchPage" && DetailFileORTitle(selectType) && len([]rune(elastic.ReplaceYH(vk))) == 1 {
 								queryItem = strings.ReplaceAll(selectType+",title", ",", "\",\"")
@@ -382,6 +395,9 @@ func getDataExportSql(scd *SieveCondition) string {
 					continue
 				} // 处理每组里面的空格分词
 				for _, notKeySplit := range strings.Split(vv, " ") {
+					if len(notKeySplit) == 0 {
+						continue
+					}
 					//单个字 搜索范围 有全文或者附件 无标题 例如:学 虚拟机 detail  搜索的时候加上标题
 					if scd.Comeinfrom == "supersearchPage" && DetailFileORTitle(selectType) && len([]rune(elastic.ReplaceYH(notKeySplit))) == 1 {
 						queryItem = strings.ReplaceAll(selectType+",title", ",", "\",\"")