|
@@ -35,7 +35,7 @@ const (
|
|
|
)
|
|
|
|
|
|
//GetWxsearchlistData 移动端招标信息搜索
|
|
|
-func GetWxsearchlistData(keywords, scope, publishtime, subtype, industry, minprice, maxprice, winner, buyerclass, hasBuyerTel, hasWinnerTel string, pageNum, pageSize int, selectTypeArr []string, field, notkey string) (list *[]map[string]interface{}, b_word, a_word, s_word string) {
|
|
|
+func GetWxsearchlistData(keywords, scope, publishtime, subtype, industry, minprice, maxprice, winner, buyerclass, hasBuyerTel, hasWinnerTel, fileExists string, pageNum, pageSize int, selectTypeArr []string, field, notkey string) (list *[]map[string]interface{}, b_word, a_word, s_word string) {
|
|
|
var hightlightContent bool = false //是否高亮正文
|
|
|
for _, v := range selectTypeArr {
|
|
|
if v == "detail" {
|
|
@@ -53,7 +53,7 @@ func GetWxsearchlistData(keywords, scope, publishtime, subtype, industry, minpri
|
|
|
} else {
|
|
|
findfields = fmt.Sprintf(`"%s"`, strings.Join(selectTypeArr, "\",\""))
|
|
|
}
|
|
|
- qstr := GetSearchQuery(s_word, industry, minprice, maxprice, hasBuyerTel, hasWinnerTel, findfields, GetBidSearchQuery(scope, publishtime, subtype, winner, buyerclass), notkey)
|
|
|
+ qstr := GetSearchQuery(s_word, industry, minprice, maxprice, hasBuyerTel, hasWinnerTel, fileExists, findfields, GetBidSearchQuery(scope, publishtime, subtype, winner, buyerclass), notkey)
|
|
|
if hightlightContent { //全文搜索
|
|
|
list = elastic.GetAllByNgram(INDEX, TYPE, qstr, `"detail"`, bidSearch_sort, field, (pageNum-1)*pageSize, pageSize, 100, true)
|
|
|
} else { //标题搜索
|
|
@@ -69,7 +69,7 @@ func GetWxsearchlistData(keywords, scope, publishtime, subtype, industry, minpri
|
|
|
}
|
|
|
|
|
|
//GetPcBidSearchData pc端招标信息搜索
|
|
|
-func GetPcBidSearchData(searchvalue, area, publishtime, subtype, industry, minprice, maxprice, winner, buyerclass, hasBuyerTel, hasWinnerTel string, start, pageSize int, isGetCount bool, selectTypeArr []string, field, notkey string, ispayed bool) (count, totalPage int64, list *[]map[string]interface{}) {
|
|
|
+func GetPcBidSearchData(searchvalue, area, publishtime, subtype, industry, minprice, maxprice, winner, buyerclass, hasBuyerTel, hasWinnerTel, fileExists string, start, pageSize int, isGetCount bool, selectTypeArr []string, field, notkey string, ispayed bool) (count, totalPage int64, list *[]map[string]interface{}) {
|
|
|
var findfields string
|
|
|
var hightlightContent bool = false //是否高亮正文
|
|
|
for _, v := range selectTypeArr {
|
|
@@ -83,7 +83,7 @@ func GetPcBidSearchData(searchvalue, area, publishtime, subtype, industry, minpr
|
|
|
} else {
|
|
|
findfields = fmt.Sprintf(`"%s"`, strings.Join(selectTypeArr, "\",\""))
|
|
|
}
|
|
|
- qstr := GetSearchQuery(searchvalue, industry, minprice, maxprice, hasBuyerTel, hasWinnerTel, findfields, GetBidSearchQuery(area, publishtime, subtype, winner, buyerclass), notkey)
|
|
|
+ qstr := GetSearchQuery(searchvalue, industry, minprice, maxprice, hasBuyerTel, hasWinnerTel, fileExists, findfields, GetBidSearchQuery(area, publishtime, subtype, winner, buyerclass), notkey)
|
|
|
if isGetCount && qstr != "" && start == 0 {
|
|
|
count = elastic.Count(INDEX, TYPE, qstr)
|
|
|
}
|
|
@@ -202,7 +202,7 @@ func GetBidSearchQuery(area, publishtime, subtype, winner, buyerclass string) st
|
|
|
return query
|
|
|
}
|
|
|
|
|
|
-func GetSearchQuery(keyword, industry, minprice, maxprice, hasBuyerTel, hasWinnerTel, findfields, mustquery, notkey string) (qstr string) {
|
|
|
+func GetSearchQuery(keyword, industry, minprice, maxprice, hasBuyerTel, hasWinnerTel, fileExists, findfields, mustquery, notkey string) (qstr string) {
|
|
|
multi_match := `{"multi_match": {"query": "%s","type": "phrase", "fields": [%s]}}`
|
|
|
query := `{"query":{"bool":{"must":[%s],"must_not":[%s]}}}`
|
|
|
query_bool_should := `{"bool":{"should":[%s],"minimum_should_match": 1}}`
|
|
@@ -215,7 +215,12 @@ func GetSearchQuery(keyword, industry, minprice, maxprice, hasBuyerTel, hasWinne
|
|
|
if mustquery != "" {
|
|
|
musts = append(musts, mustquery)
|
|
|
}
|
|
|
+
|
|
|
+ var isFileSearch bool = false //搜索范围是否有附件选择
|
|
|
if keyword != "" {
|
|
|
+ if strings.Contains(findfields, "filetext") { //搜索范围选择附件,是否有附件条件无效;
|
|
|
+ isFileSearch = true
|
|
|
+ }
|
|
|
keyword_multi_match := fmt.Sprintf(multi_match, "%s", findfields)
|
|
|
shoulds := []string{}
|
|
|
for _, v := range strings.Split(keyword, "+") {
|
|
@@ -283,6 +288,13 @@ func GetSearchQuery(keyword, industry, minprice, maxprice, hasBuyerTel, hasWinne
|
|
|
}
|
|
|
must_not = append(must_not, fmt.Sprintf(query_bool_should, strings.Join(notkey_must_not, ",")))
|
|
|
}
|
|
|
+ if !isFileSearch && fileExists != "" {
|
|
|
+ if fileExists == "1" { //有附件
|
|
|
+ must_not = append(must_not, fmt.Sprintf(query_missing, "filetext"))
|
|
|
+ } else if fileExists == "-1" { //无附件
|
|
|
+ musts = append(musts, fmt.Sprintf(query_missing, "filetext"))
|
|
|
+ }
|
|
|
+ }
|
|
|
qstr = fmt.Sprintf(query, strings.Join(musts, ","), strings.Join(must_not, ","))
|
|
|
log.Println(qstr)
|
|
|
return
|
|
@@ -321,7 +333,7 @@ func PublicSearch(userId, selectType, publishtime string, bidSearchOldUserLimit
|
|
|
}
|
|
|
|
|
|
//所有的再次分词查询 只查标题
|
|
|
-func IntegratedData(platform string, s_word, secondKWS, industry, minprice, maxprice, hasBuyerTel, hasWinnerTel, secondFlag, area, publishtime, subtype, buyerclass, notkey string, queryItems []string, list *[]map[string]interface{}) (string, string, string, string, *[]map[string]interface{}) {
|
|
|
+func IntegratedData(platform string, s_word, secondKWS, industry, minprice, maxprice, hasBuyerTel, hasWinnerTel, fileExists, secondFlag, area, publishtime, subtype, buyerclass, notkey string, queryItems []string, list *[]map[string]interface{}) (string, string, string, string, *[]map[string]interface{}) {
|
|
|
var pcAjaxFlag string
|
|
|
secondSearch := false
|
|
|
var secRel *[]map[string]interface{} = list
|
|
@@ -334,7 +346,7 @@ func IntegratedData(platform string, s_word, secondKWS, industry, minprice, maxp
|
|
|
if secondSearch {
|
|
|
if secondKWS = jy.HttpEs(s_word, "ik_smart", public.DbConf.Elasticsearch.Main.Address); secondKWS != "" {
|
|
|
findfields := `"title"`
|
|
|
- qstr := GetSearchQuery(secondKWS, industry, minprice, maxprice, hasBuyerTel, hasWinnerTel, findfields, GetBidSearchQuery(area, publishtime, subtype, "", buyerclass), notkey)
|
|
|
+ qstr := GetSearchQuery(secondKWS, industry, minprice, maxprice, hasBuyerTel, hasWinnerTel, fileExists, findfields, GetBidSearchQuery(area, publishtime, subtype, "", buyerclass), notkey)
|
|
|
secRel = elastic.GetAllByNgram(INDEX, TYPE, qstr, findfields, bidSearch_sort, bidSearch_field, 0, 2*SearchPageSize_PC, 0, false)
|
|
|
if secRel != nil && len(*secRel) > 0 {
|
|
|
public.BidListConvert(industry, secRel)
|
|
@@ -419,6 +431,10 @@ func LisetData(stype, pageNum int, list *[]map[string]interface{}, secondFlag st
|
|
|
}
|
|
|
v["detail"] = detail
|
|
|
v["href"] = util.EncodeArticleId2ByCheck(util.GetRandom(20))
|
|
|
+ if v["filetext"] != nil {
|
|
|
+ delete(v, "filetext")
|
|
|
+ v["fileExists"] = true
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
if secondFlag != "" {
|
|
@@ -446,21 +462,21 @@ func LisetData(stype, pageNum int, list *[]map[string]interface{}, secondFlag st
|
|
|
return secondList, totalPage, hasNextPage
|
|
|
}
|
|
|
|
|
|
-func SearchData(platform string, request *http.Request, currentPage int, userId, secondKWS, s_word, area, publishtime, subtype, industry, minprice, maxprice, winner, buyerclass, hasBuyerTel, hasWinnerTel string, start, pageSize int, isGetCount bool, queryItems []string, field, notkey string, isPayedUser bool) (second, b_word, a_word, pcAjaxFlag, secondFlag string, count, totalPage int64, list *[]map[string]interface{}) {
|
|
|
+func SearchData(platform string, request *http.Request, currentPage int, userId, secondKWS, s_word, area, publishtime, subtype, industry, minprice, maxprice, winner, buyerclass, hasBuyerTel, hasWinnerTel, fileExists string, start, pageSize int, isGetCount bool, queryItems []string, field, notkey string, isPayedUser bool) (second, b_word, a_word, pcAjaxFlag, secondFlag string, count, totalPage int64, list *[]map[string]interface{}) {
|
|
|
var searchvalue = s_word
|
|
|
number := util.If(platform == "app" || platform == "wx", 1, 0)
|
|
|
if platform == "app" || platform == "wx" {
|
|
|
- list, b_word, a_word, s_word = GetWxsearchlistData(s_word, area, publishtime, subtype, industry, minprice, maxprice, winner, buyerclass, hasBuyerTel, hasWinnerTel, start, SearchPageSize_APP, queryItems, field, notkey)
|
|
|
+ list, b_word, a_word, s_word = GetWxsearchlistData(s_word, area, publishtime, subtype, industry, minprice, maxprice, winner, buyerclass, hasBuyerTel, hasWinnerTel, fileExists, start, SearchPageSize_APP, queryItems, field, notkey)
|
|
|
if list != nil && len(*list) != 0 {
|
|
|
count = int64(len(*list))
|
|
|
}
|
|
|
} else {
|
|
|
- count, totalPage, list = GetPcBidSearchData(s_word, area, publishtime, subtype, industry, minprice, maxprice, winner, buyerclass, hasBuyerTel, hasWinnerTel, start, pageSize, isGetCount, queryItems, field, notkey, isPayedUser)
|
|
|
+ count, totalPage, list = GetPcBidSearchData(s_word, area, publishtime, subtype, industry, minprice, maxprice, winner, buyerclass, hasBuyerTel, hasWinnerTel, fileExists, start, pageSize, isGetCount, queryItems, field, notkey, isPayedUser)
|
|
|
}
|
|
|
|
|
|
if len([]rune(s_word)) > 3 && int(count) < SearchPageSize_PC && start == number {
|
|
|
var paramList = list
|
|
|
- s_word, pcAjaxFlag, secondFlag, second, list = IntegratedData(platform, s_word, secondKWS, industry, minprice, maxprice, hasBuyerTel, hasWinnerTel, secondFlag, area, publishtime, subtype, buyerclass, notkey, queryItems, paramList)
|
|
|
+ s_word, pcAjaxFlag, secondFlag, second, list = IntegratedData(platform, s_word, secondKWS, industry, minprice, maxprice, hasBuyerTel, hasWinnerTel, fileExists, secondFlag, area, publishtime, subtype, buyerclass, notkey, queryItems, paramList)
|
|
|
}
|
|
|
|
|
|
listSize := 0
|