|
@@ -501,7 +501,7 @@ func (m *Front) PcAjaxReq() {
|
|
|
if selectType == "" {
|
|
|
selectType = "all"
|
|
|
}
|
|
|
- _, a_word, s_word := InterceptSearchKW(m.GetString("searchvalue"), selectType == "all")
|
|
|
+ _, a_word, s_word := InterceptSearchKW(m.GetString("searchvalue"), selectType == "all", true)
|
|
|
var list *[]map[string]interface{}
|
|
|
var count, totalPage int64
|
|
|
status, _ := m.GetInteger("status")
|
|
@@ -845,8 +845,7 @@ func (m *Front) Wxsearch() error {
|
|
|
//剑鱼微信查询结果页面
|
|
|
func (m *Front) Wxsearchlist() error {
|
|
|
defer util.Catch()
|
|
|
- keywords := m.GetString("searchname")
|
|
|
- searchvalue := m.GetString("searchvalue")
|
|
|
+ keywords := strings.TrimSpace(m.GetString("searchname"))
|
|
|
toptype := m.GetString("toptype")
|
|
|
subtype := m.GetString("subtype")
|
|
|
industry := strings.TrimSpace(m.GetString("industry"))
|
|
@@ -864,13 +863,13 @@ func (m *Front) Wxsearchlist() error {
|
|
|
m.SetSession("scope", scope)
|
|
|
m.SetSession("publishtime", publishtime)
|
|
|
var list *[]map[string]interface{}
|
|
|
+ var s_word string
|
|
|
if userid := m.GetSession("userId"); userid != nil {
|
|
|
if len(keywords) > 0 {
|
|
|
if selectType == "" { //默认设置为全文搜索
|
|
|
selectType = "all"
|
|
|
}
|
|
|
- list = getWxsearchlistData(keywords, searchvalue, scope, publishtime, subtype, industry, minprice, maxprice, 1, selectType, bidSearch_field)
|
|
|
-
|
|
|
+ list, _, _, s_word = getWxsearchlistData(keywords, scope, publishtime, subtype, industry, minprice, maxprice, 1, selectType, bidSearch_field)
|
|
|
r := redis.GetStr("other", "s_"+userid.(string))
|
|
|
arrs := strings.Split(r, ",")
|
|
|
if r == "" {
|
|
@@ -896,7 +895,7 @@ func (m *Front) Wxsearchlist() error {
|
|
|
m.T["list"] = list
|
|
|
m.T["pageSize"] = wx_pageSize
|
|
|
m.T["keywords"] = keywords
|
|
|
- m.T["searchvalue"] = searchvalue
|
|
|
+ m.T["searchvalue"] = s_word
|
|
|
m.T["toptype"] = toptype
|
|
|
m.T["subtype"] = subtype
|
|
|
m.T["scope"] = scope
|
|
@@ -925,21 +924,21 @@ func (m *Front) WxsearchlistPaging() {
|
|
|
one, _ := mongodb.FindOneByField("user", bson.M{"_id": bson.ObjectIdHex(userid.(string))}, `{"o_jy":1}`)
|
|
|
history := redis.GetStr("other", "s_"+userid.(string))
|
|
|
arrs := strings.Split(history, ",")
|
|
|
- searchvalue := strings.Trim(m.GetString("searchvalue"), " ")
|
|
|
+ searchvalue := strings.TrimSpace(m.GetString("searchvalue"))
|
|
|
+ var b_word, a_word string
|
|
|
if searchvalue != "" {
|
|
|
- searchname := strings.Replace(strings.Replace(searchvalue, " ", "+", -1), "++", "+", -1)
|
|
|
+ selectType := m.GetString("selectType")
|
|
|
subtype := m.GetString("subtype")
|
|
|
scope := m.GetString("scope")
|
|
|
publishtime := m.GetString("publishtime")
|
|
|
- selectType := m.GetString("selectType")
|
|
|
industry := strings.TrimSpace(m.GetString("industry"))
|
|
|
m.SetSession("industry", industry)
|
|
|
minprice := m.GetString("minprice")
|
|
|
maxprice := m.GetString("maxprice")
|
|
|
if open_supersearch {
|
|
|
- list = getWxsearchlistData(searchvalue, searchname, scope, publishtime, subtype, industry, minprice, maxprice, pageNum, selectType, bidSearch_field)
|
|
|
+ list, b_word, a_word, _ = getWxsearchlistData(searchvalue, scope, publishtime, subtype, industry, minprice, maxprice, pageNum, selectType, bidSearch_field)
|
|
|
} else {
|
|
|
- list = getWxsearchlistData(searchvalue, searchname, scope, publishtime, subtype, "", "", "", pageNum, selectType, bidSearch_field)
|
|
|
+ list, b_word, a_word, _ = getWxsearchlistData(searchvalue, scope, publishtime, subtype, "", "", "", pageNum, selectType, bidSearch_field)
|
|
|
}
|
|
|
//新增历史记录
|
|
|
if history == "" {
|
|
@@ -972,10 +971,12 @@ func (m *Front) WxsearchlistPaging() {
|
|
|
m.T["msgset"] = keys
|
|
|
}
|
|
|
m.ServeJson(map[string]interface{}{
|
|
|
- "list": list,
|
|
|
- "hasNextPage": list != nil && len(*list) == wx_pageSize && pageNum < wx_maxPageNum,
|
|
|
- "history": m.T["history"],
|
|
|
- "msgset": m.T["msgset"],
|
|
|
+ "list": list,
|
|
|
+ "hasNextPage": list != nil && len(*list) == wx_pageSize && pageNum < wx_maxPageNum,
|
|
|
+ "history": m.T["history"],
|
|
|
+ "msgset": m.T["msgset"],
|
|
|
+ "interceptWord": a_word,
|
|
|
+ "keyWord": b_word,
|
|
|
})
|
|
|
}
|
|
|
}
|
|
@@ -996,22 +997,16 @@ func (m *Front) DelWxHistorySearch() {
|
|
|
}
|
|
|
|
|
|
//微信端搜索
|
|
|
-func getWxsearchlistData(keywords, searchvalue, scope, publishtime, subtype, industry, minprice, maxprice string, pageNum int, selectType, field string) (list *[]map[string]interface{}) {
|
|
|
- //scope是地区对应传进的areas, stype是类型对应scope
|
|
|
- if len(industry) > 0 {
|
|
|
- keywords = strings.TrimSpace(keywords)
|
|
|
- } else {
|
|
|
- keywords = FilteKey(keywords)
|
|
|
- }
|
|
|
- if len(keywords) == 0 {
|
|
|
- return list
|
|
|
+func getWxsearchlistData(keywords, scope, publishtime, subtype, industry, minprice, maxprice string, pageNum int, selectType, field string) (list *[]map[string]interface{}, b_word, a_word, s_word string) {
|
|
|
+ b_word, a_word, s_word = InterceptSearchKW(keywords, selectType == "all", len(industry) == 0)
|
|
|
+ if len(b_word) == 0 {
|
|
|
+ return list, b_word, a_word, s_word
|
|
|
}
|
|
|
- fmt.Print("keywords>>>", keywords, "searchvalue>>", searchvalue)
|
|
|
findfields := `"title"`
|
|
|
if selectType == "all" {
|
|
|
findfields = `"title","detail"`
|
|
|
}
|
|
|
- qstr := getSearchQuery(searchvalue, industry, minprice, maxprice, findfields, getBidSearchQuery(scope, publishtime, subtype))
|
|
|
+ qstr := getSearchQuery(s_word, industry, minprice, maxprice, findfields, getBidSearchQuery(scope, publishtime, subtype))
|
|
|
if selectType == "all" { //全文搜索
|
|
|
list = elastic.GetAllByNgram(INDEX, TYPE, qstr, findfields, bidSearch_sort, field, (pageNum-1)*wx_pageSize, wx_pageSize, 100, true)
|
|
|
} else { //标题搜索
|
|
@@ -1024,7 +1019,7 @@ func getWxsearchlistData(keywords, searchvalue, scope, publishtime, subtype, ind
|
|
|
v["_id"] = util.EncodeArticleId2ByCheck(util.ObjToString(v["_id"]))
|
|
|
}
|
|
|
}
|
|
|
- return list
|
|
|
+ return list, b_word, a_word, s_word
|
|
|
}
|
|
|
|
|
|
//查看原文跳转
|