|
@@ -53,7 +53,7 @@ func GetWxsearchlistData(keywords, scope, city, publishtime, subtype, industry,
|
|
|
} else {
|
|
|
findfields = fmt.Sprintf(`"%s"`, strings.Join(selectTypeArr, "\",\""))
|
|
|
}
|
|
|
- qstr := GetSearchQuery(s_word, industry, minprice, maxprice, hasBuyerTel, hasWinnerTel, fileExists, findfields, GetBidSearchQuery(scope, city, publishtime, subtype, winner, buyerclass), notkey, searchTypeSwitch)
|
|
|
+ qstr := GetSearchQuery(s_word, industry, minprice, maxprice, hasBuyerTel, hasWinnerTel, fileExists, findfields, GetBidSearchQuery(scope, city, publishtime, subtype, winner, buyerclass), notkey, searchTypeSwitch, "")
|
|
|
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, city, publishtime, subtype, industry,
|
|
|
}
|
|
|
|
|
|
//GetPcBidSearchData pc端招标信息搜索
|
|
|
-func GetPcBidSearchData(searchvalue, area, city, publishtime, subtype, industry, minprice, maxprice, winner, buyerclass, hasBuyerTel, hasWinnerTel, fileExists string, start, pageSize int, isGetCount bool, selectTypeArr []string, field, notkey string, ispayed, searchTypeSwitch bool) (count, totalPage int64, list *[]map[string]interface{}) {
|
|
|
+func GetPcBidSearchData(searchvalue, area, city, publishtime, subtype, industry, minprice, maxprice, winner, buyerclass, hasBuyerTel, hasWinnerTel, fileExists string, start, pageSize int, isGetCount bool, selectTypeArr []string, field, notkey string, ispayed, searchTypeSwitch bool, bidField string) (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, city, publishtime, subtype, industry,
|
|
|
} else {
|
|
|
findfields = fmt.Sprintf(`"%s"`, strings.Join(selectTypeArr, "\",\""))
|
|
|
}
|
|
|
- qstr := GetSearchQuery(searchvalue, industry, minprice, maxprice, hasBuyerTel, hasWinnerTel, fileExists, findfields, GetBidSearchQuery(area, city, publishtime, subtype, winner, buyerclass), notkey, searchTypeSwitch)
|
|
|
+ qstr := GetSearchQuery(searchvalue, industry, minprice, maxprice, hasBuyerTel, hasWinnerTel, fileExists, findfields, GetBidSearchQuery(area, city, publishtime, subtype, winner, buyerclass), notkey, searchTypeSwitch, bidField)
|
|
|
if isGetCount && qstr != "" && start == 0 {
|
|
|
count = elastic.Count(INDEX, TYPE, qstr)
|
|
|
}
|
|
@@ -246,7 +246,7 @@ func DetailFileORTitle(findfields string) bool {
|
|
|
func DetailTitle(findfields string) bool {
|
|
|
return strings.Contains(findfields, `"detail"`) && strings.Contains(findfields, `"title"`)
|
|
|
}
|
|
|
-func GetSearchQuery(keyword, industry, minprice, maxprice, hasBuyerTel, hasWinnerTel, fileExists, findfields, mustquery, notkey string, searchTypeSwitch bool) (qstr string) {
|
|
|
+func GetSearchQuery(keyword, industry, minprice, maxprice, hasBuyerTel, hasWinnerTel, fileExists, findfields, mustquery, notkey string, searchTypeSwitch bool, bidField string) (qstr string) {
|
|
|
multi_match := `{"multi_match": {"query": "%s","type": "phrase", "fields": [%s]}}`
|
|
|
query := `{"query":{"bool":{"must":[%s],"must_not":[%s]}}}`
|
|
|
//query := `{"query": {"function_score": {"query": {"bool": {"must": [%s],"must_not": [%s]}},"field_value_factor": {"field": "dataweight","modifier": "ln1p","missing": 0}}}}`
|
|
@@ -255,6 +255,7 @@ func GetSearchQuery(keyword, industry, minprice, maxprice, hasBuyerTel, hasWinne
|
|
|
query_bool_must := `{"bool":{"must":[{"terms":{"s_subscopeclass":[%s]}}]}}`
|
|
|
query_missing := `{"constant_score":{"filter":{"missing":{"field":"%s"}}}}`
|
|
|
query_bool_must_term := `{"bool": {"must": [{ "term": {"isValidFile": %d }}]}}`
|
|
|
+ query_bool_must_term_domain := `{"bool": {"must": [{ "term": {"bid_field": "%s"" }}]}}` // 领域化数据类型
|
|
|
gte := `"gte": %s`
|
|
|
lte := `"lte": %s`
|
|
|
musts, must_not := []string{}, []string{}
|
|
@@ -365,6 +366,10 @@ func GetSearchQuery(keyword, industry, minprice, maxprice, hasBuyerTel, hasWinne
|
|
|
musts = append(musts, fmt.Sprintf(query_missing, "isValidFile"))
|
|
|
}
|
|
|
}
|
|
|
+ // 如果是领域化数据则需要加标签
|
|
|
+ if bidField != "" {
|
|
|
+ musts = append(musts, fmt.Sprintf(query_bool_must_term_domain, bidField))
|
|
|
+ }
|
|
|
qstr = fmt.Sprintf(query, strings.Join(musts, ","), strings.Join(must_not, ","))
|
|
|
log.Println(qstr)
|
|
|
return
|
|
@@ -403,12 +408,12 @@ func PublicSearch(userId, selectType, publishtime string, bidSearchOldUserLimit
|
|
|
}
|
|
|
|
|
|
//所有的再次分词查询 只查标题
|
|
|
-func IntegratedData(platform string, s_word, secondKWS, industry, minprice, maxprice, hasBuyerTel, hasWinnerTel, fileExists, secondFlag, area, city, publishtime, subtype, buyerclass, notkey string, queryItems []string, list *[]map[string]interface{}, field string, searchTypeSwitch bool) (string, string, string, string, *[]map[string]interface{}) {
|
|
|
+func IntegratedData(platform string, s_word, secondKWS, industry, minprice, maxprice, hasBuyerTel, hasWinnerTel, fileExists, secondFlag, area, city, publishtime, subtype, buyerclass, notkey string, queryItems []string, list *[]map[string]interface{}, field string, searchTypeSwitch bool, bidField string) (string, string, string, string, *[]map[string]interface{}) {
|
|
|
var pcAjaxFlag string
|
|
|
var secRel *[]map[string]interface{} = list
|
|
|
if secondKWS = jy.HttpEs(s_word, "ik_smart", public.DbConf.Elasticsearch.Main.Address); secondKWS != "" {
|
|
|
findfields := `"title"`
|
|
|
- qstr := GetSearchQuery(secondKWS, industry, minprice, maxprice, hasBuyerTel, hasWinnerTel, fileExists, findfields, GetBidSearchQuery(area, city, publishtime, subtype, "", buyerclass), notkey, searchTypeSwitch)
|
|
|
+ qstr := GetSearchQuery(secondKWS, industry, minprice, maxprice, hasBuyerTel, hasWinnerTel, fileExists, findfields, GetBidSearchQuery(area, city, publishtime, subtype, "", buyerclass), notkey, searchTypeSwitch, bidField)
|
|
|
secRel = elastic.GetAllByNgram(INDEX, TYPE, qstr, findfields, bidSearch_sort, field, 0, 2*SearchPageSize_PC, 0, false)
|
|
|
if secRel != nil && len(*secRel) > 0 {
|
|
|
public.BidListConvert(industry, secRel)
|
|
@@ -523,7 +528,7 @@ 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, city, publishtime, subtype, industry, minprice, maxprice, winner, buyerclass, hasBuyerTel, hasWinnerTel, fileExists string, start, pageSize int, isGetCount bool, queryItems []string, field, notkey string, isPayedUser, searchTypeSwitch 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, city, publishtime, subtype, industry, minprice, maxprice, winner, buyerclass, hasBuyerTel, hasWinnerTel, fileExists string, start, pageSize int, isGetCount bool, queryItems []string, field, notkey string, isPayedUser, searchTypeSwitch bool, bidField string) (second, b_word, a_word, pcAjaxFlag, secondFlag string, count, totalPage int64, list *[]map[string]interface{}) {
|
|
|
//包含标题才能进行二次搜索
|
|
|
var secondSearch = strings.Contains(strings.Join(queryItems, ","), "title")
|
|
|
var searchvalue = s_word
|
|
@@ -534,12 +539,12 @@ func SearchData(platform string, request *http.Request, currentPage int, userId,
|
|
|
count = int64(len(*list))
|
|
|
}
|
|
|
} else {
|
|
|
- count, totalPage, list = GetPcBidSearchData(s_word, area, city, publishtime, subtype, industry, minprice, maxprice, winner, buyerclass, hasBuyerTel, hasWinnerTel, fileExists, start, pageSize, isGetCount, queryItems, field, notkey, isPayedUser, searchTypeSwitch)
|
|
|
+ count, totalPage, list = GetPcBidSearchData(s_word, area, city, publishtime, subtype, industry, minprice, maxprice, winner, buyerclass, hasBuyerTel, hasWinnerTel, fileExists, start, pageSize, isGetCount, queryItems, field, notkey, isPayedUser, searchTypeSwitch, bidField)
|
|
|
}
|
|
|
|
|
|
if len([]rune(s_word)) > 3 && int(count) < SearchPageSize_PC && start == number && secondSearch {
|
|
|
var paramList = list
|
|
|
- s_word, pcAjaxFlag, secondFlag, second, list = IntegratedData(platform, s_word, secondKWS, industry, minprice, maxprice, hasBuyerTel, hasWinnerTel, fileExists, secondFlag, area, city, publishtime, subtype, buyerclass, notkey, queryItems, paramList, field, searchTypeSwitch)
|
|
|
+ s_word, pcAjaxFlag, secondFlag, second, list = IntegratedData(platform, s_word, secondKWS, industry, minprice, maxprice, hasBuyerTel, hasWinnerTel, fileExists, secondFlag, area, city, publishtime, subtype, buyerclass, notkey, queryItems, paramList, field, searchTypeSwitch, bidField)
|
|
|
}
|
|
|
|
|
|
listSize := 0
|