|
@@ -4,6 +4,7 @@ import (
|
|
|
"encoding/json"
|
|
|
"errors"
|
|
|
"fmt"
|
|
|
+ "log"
|
|
|
"models"
|
|
|
"qfw/util"
|
|
|
"qfw/util/elastic"
|
|
@@ -18,29 +19,31 @@ import (
|
|
|
)
|
|
|
|
|
|
const (
|
|
|
- TitleMatchType = "1" //标题匹配
|
|
|
- DetailMatchType = "2" //全文匹配
|
|
|
- PurchasingMatchType = "3" //标的物匹配
|
|
|
- AttachmentsMatchType = "4" //附件匹配
|
|
|
- ProjectnameMatchType = "5" //项目名称匹配
|
|
|
- BuyerMatchType = "6" //采购单位匹配
|
|
|
- SWinnerMatchType = "7" //中标单位匹配
|
|
|
- BuyerMatchType1 = "8" //采购单位(正则)匹配
|
|
|
- SWinnerMatchType1 = "9" //中标单位(正则)匹配
|
|
|
- TitleMatchTypeStr = "title" //标题匹配
|
|
|
- DetailMatchTypeStr = "detail" //全文匹配
|
|
|
- PurchasingMatchTypeStr = "purchasing" //标的物匹配
|
|
|
- AttachmentsMatchTypeStr = "filetext" //附件匹配
|
|
|
- ProjectnameMatchTypeStr = "projectname" //项目名称匹配
|
|
|
- BuyerMatchTypeStr = "buyer" //项目名称匹配
|
|
|
- SWinnerMatchTypeStr = "s_winner" //项目名称匹配
|
|
|
- TitleMatchTypeField = "title" //标题匹配
|
|
|
- DetailMatchTypeField = "detail" //全文匹配
|
|
|
- PurchasingMatchTypeField = "purchasing" //标的物匹配
|
|
|
- AttachmentsMatchTypeField = "filetext" //附件匹配
|
|
|
- ProjectnameMatchTypeField = "projectname" //项目名称匹配
|
|
|
- BuyerMatchTypeField = "buyer" //项目名称匹配
|
|
|
- SWinnerMatchTypeField = "s_winner" //项目名称匹配
|
|
|
+ TitleMatchType = "1" //标题匹配
|
|
|
+ DetailMatchType = "2" //全文匹配
|
|
|
+ PurchasingMatchType = "3" //标的物匹配
|
|
|
+ AttachmentsMatchType = "4" //附件匹配
|
|
|
+ ProjectnameMatchType = "5" //项目名称匹配
|
|
|
+ BuyerMatchType = "6" //采购单位匹配
|
|
|
+ SWinnerMatchType = "7" //中标单位匹配
|
|
|
+ BuyerMatchType1 = "8" //采购单位(正则)匹配
|
|
|
+ SWinnerMatchType1 = "9" //中标单位(正则)匹配
|
|
|
+ TitleMatchTypeStr = "title" //标题匹配
|
|
|
+ DetailMatchTypeStr = "detail" //全文匹配
|
|
|
+ PurchasingMatchTypeStr = "purchasing" //标的物匹配
|
|
|
+ AttachmentsMatchTypeStr = "filetext" //附件匹配
|
|
|
+ ProjectnameMatchTypeStr = "projectname" //项目名称匹配
|
|
|
+ BuyerMatchTypeStr = "buyer" //项目名称匹配
|
|
|
+ BuyerRegexpMatchTypeStr = "buyer.mbuyer" //采购单位正则匹配
|
|
|
+ SWinnerMatchTypeStr = "s_winner" //项目名称匹配
|
|
|
+ SWinnerRegexpMatchTypeStr = "s_winner.mwinner" //中标单位正则匹配
|
|
|
+ TitleMatchTypeField = "title" //标题匹配
|
|
|
+ DetailMatchTypeField = "detail" //全文匹配
|
|
|
+ PurchasingMatchTypeField = "purchasing" //标的物匹配
|
|
|
+ AttachmentsMatchTypeField = "filetext" //附件匹配
|
|
|
+ ProjectnameMatchTypeField = "projectname" //项目名称匹配
|
|
|
+ BuyerMatchTypeField = "buyer" //项目名称匹配
|
|
|
+ SWinnerMatchTypeField = "s_winner" //项目名称匹配
|
|
|
MultiMatchType = "phrase"
|
|
|
Standard = 1 //1:标准字段包,
|
|
|
Advanced = 2 //2:高级字段包
|
|
@@ -220,6 +223,7 @@ func Utiltags(tag map[string]interface{}) string {
|
|
|
if err != nil {
|
|
|
return "json err:" + err.Error()
|
|
|
}
|
|
|
+ log.Println("前端数据", tab)
|
|
|
QueryObjecct := sql.QueryObjecct{}
|
|
|
ffBoolObject := sql.BoolObject{}
|
|
|
adsBoolObect := sql.NewEsObject{}
|
|
@@ -468,9 +472,9 @@ func strsToArr(strs string, typestr string) []string {
|
|
|
case SWinnerMatchType:
|
|
|
tmps[index] = SWinnerMatchTypeStr
|
|
|
case BuyerMatchType1:
|
|
|
- tmps[index] = BuyerMatchTypeStr
|
|
|
+ tmps[index] = BuyerRegexpMatchTypeStr
|
|
|
case SWinnerMatchType1:
|
|
|
- tmps[index] = SWinnerMatchTypeStr
|
|
|
+ tmps[index] = SWinnerRegexpMatchTypeStr
|
|
|
}
|
|
|
}
|
|
|
return tmps
|
|
@@ -508,29 +512,44 @@ func init() {
|
|
|
}
|
|
|
|
|
|
func method1(newEsObject sql.NewEsObject, keyword, keymatch string, tmps []string) sql.NewEsObject {
|
|
|
+ keywordArr := []string{}
|
|
|
for _, vv := range strings.Split(keyword, ",") {
|
|
|
if vv == "" {
|
|
|
continue
|
|
|
}
|
|
|
+ log.Println(vv, tmps, keymatch)
|
|
|
if len(tmps) == 1 && (strings.Contains(keymatch, "8") || strings.Contains(keymatch, "9")) {
|
|
|
//中标单位、采购单位、中标单位(正则)、采购单位(正则) 单选
|
|
|
strs := ""
|
|
|
if strings.Contains(vv, "&&") {
|
|
|
- strs = ".*" + strings.Replace(vv, "&&", ".*", -1) + ".*"
|
|
|
+ //strs = ".*" + strings.Replace(vv, "&&", ".*", -1) + ".*"
|
|
|
+ strs = strings.Replace(vv, "&&", ".*", -1)
|
|
|
} else {
|
|
|
- strs = ".*" + vv + ".*"
|
|
|
+ strs = vv
|
|
|
}
|
|
|
- if tmps[0] == "buyer" {
|
|
|
- newEsObject.Bool.Should = append(newEsObject.Bool.Should, sql.Regular{
|
|
|
- Regexp1: &sql.Regular_Buyer{Buyer: strs},
|
|
|
+ if tmps[0] == "buyer.mbuyer" {
|
|
|
+ newEsObject.Bool.Should = append(newEsObject.Bool.Should, sql.ShouldObj{
|
|
|
+ MultiMatch: &sql.MultiMatch{
|
|
|
+ Query: strs,
|
|
|
+ Type: MultiMatchType,
|
|
|
+ Fields: tmps,
|
|
|
+ },
|
|
|
})
|
|
|
- } else if tmps[0] == "s_winner" {
|
|
|
- newEsObject.Bool.Should = append(newEsObject.Bool.Should, sql.Regular{
|
|
|
- Regexp2: &sql.Regular_winner{Winner: strs},
|
|
|
+ } else if tmps[0] == "s_winner.mwinner" {
|
|
|
+ newEsObject.Bool.Should = append(newEsObject.Bool.Should, sql.ShouldObj{
|
|
|
+ MultiMatch: &sql.MultiMatch{
|
|
|
+ Query: strs,
|
|
|
+ Type: MultiMatchType,
|
|
|
+ Fields: tmps,
|
|
|
+ },
|
|
|
})
|
|
|
}
|
|
|
+ } else if len(tmps) == 1 && (strings.Contains(keymatch, "6") || strings.Contains(keymatch, "7")) {
|
|
|
+ addkeylines := strings.Split(vv, "&&")
|
|
|
+ keywordArr = append(keywordArr, addkeylines[0])
|
|
|
} else {
|
|
|
addkeylines := strings.Split(vv, "&&")
|
|
|
+ log.Println(addkeylines, "addkeylines")
|
|
|
if len(addkeylines) > 1 {
|
|
|
addkeyline := sql.NewEsObject{}
|
|
|
for _, vvv := range addkeylines {
|
|
@@ -559,6 +578,21 @@ func method1(newEsObject sql.NewEsObject, keyword, keymatch string, tmps []strin
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ if len(tmps) == 1 && (strings.Contains(keymatch, "6") || strings.Contains(keymatch, "7")) {
|
|
|
+ addkeyline := sql.NewEsObject{}
|
|
|
+ if tmps[0] == "buyer" {
|
|
|
+ addkeyline.Bool.Must = append(addkeyline.Bool.Must, sql.BuyerMatch{
|
|
|
+ Buyer: &sql.Buyer{Buyer: keywordArr},
|
|
|
+ })
|
|
|
+ } else if tmps[0] == "s_winner" {
|
|
|
+ addkeyline.Bool.Must = append(addkeyline.Bool.Must, sql.WinnerMatch{
|
|
|
+ Winner: &sql.Winner{Winner: keywordArr},
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if len(addkeyline.Bool.Must) > 0 {
|
|
|
+ newEsObject.Bool.Should = append(newEsObject.Bool.Should, addkeyline)
|
|
|
+ }
|
|
|
+ }
|
|
|
return newEsObject
|
|
|
}
|
|
|
|
|
@@ -569,19 +603,27 @@ func method2(newEsObject sql.NewEsObject, keyword, keymatch string, tmps []strin
|
|
|
}
|
|
|
if len(tmps) == 1 && (strings.Contains(keymatch, "8") || strings.Contains(keymatch, "9")) {
|
|
|
//中标单位、采购单位、中标单位(正则)、采购单位(正则) 单选
|
|
|
- strs := ""
|
|
|
- if strings.Contains(vv, "&&") {
|
|
|
- strs = ".*" + strings.Replace(vv, "&&", ".*", -1) + ".*"
|
|
|
- } else {
|
|
|
- strs = ".*" + vv + ".*"
|
|
|
- }
|
|
|
+ //strs := ""
|
|
|
+ //if strings.Contains(vv, "&&") {
|
|
|
+ // strs = ".*" + strings.Replace(vv, "&&", ".*", -1) + ".*"
|
|
|
+ //} else {
|
|
|
+ // strs = ".*" + vv + ".*"
|
|
|
+ //}
|
|
|
if tmps[0] == "buyer" {
|
|
|
- newEsObject.Bool.MustNot = append(newEsObject.Bool.MustNot, sql.Regular{
|
|
|
- Regexp1: &sql.Regular_Buyer{Buyer: strs},
|
|
|
+ newEsObject.Bool.MustNot = append(newEsObject.Bool.MustNot, sql.ShouldObj{
|
|
|
+ MultiMatch: &sql.MultiMatch{
|
|
|
+ Query: vv,
|
|
|
+ Type: MultiMatchType,
|
|
|
+ Fields: tmps,
|
|
|
+ },
|
|
|
})
|
|
|
} else if tmps[0] == "s_winner" {
|
|
|
- newEsObject.Bool.MustNot = append(newEsObject.Bool.MustNot, sql.Regular{
|
|
|
- Regexp2: &sql.Regular_winner{Winner: strs},
|
|
|
+ newEsObject.Bool.MustNot = append(newEsObject.Bool.MustNot, sql.ShouldObj{
|
|
|
+ MultiMatch: &sql.MultiMatch{
|
|
|
+ Query: vv,
|
|
|
+ Type: MultiMatchType,
|
|
|
+ Fields: tmps,
|
|
|
+ },
|
|
|
})
|
|
|
}
|
|
|
} else {
|