|
@@ -35,7 +35,7 @@ type Tags struct {
|
|
|
|
|
|
var LetterArr = []string{"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"}
|
|
var LetterArr = []string{"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"}
|
|
var bidField = `"_id","site","title","publishtime","toptype","subtype","type","area","href","bidopentime","winner","buyer","bidamount","budget","s_subscopeclass","projectname","detail"`
|
|
var bidField = `"_id","site","title","publishtime","toptype","subtype","type","area","href","bidopentime","winner","buyer","bidamount","budget","s_subscopeclass","projectname","detail"`
|
|
-var seoBidField = `"_id","title","publishtime","subtype","area","href","bidamount","budget","s_subscopeclass","projectname","detail"`
|
|
|
|
|
|
+var seoBidField = `"_id","title","publishtime","subtype","area","href","bidamount","budget","s_subscopeclass","projectname"`
|
|
|
|
|
|
func init() {
|
|
func init() {
|
|
xweb.AddAction(&Tags{})
|
|
xweb.AddAction(&Tags{})
|
|
@@ -604,7 +604,7 @@ func (this *Tags) GetBidding(industry, area, city, stype, keyword string, reques
|
|
rediskey := fmt.Sprintf("pcseo_getbidding_%s_%s_%s_%s_%s", industry, area, city, stype, keyword)
|
|
rediskey := fmt.Sprintf("pcseo_getbidding_%s_%s_%s_%s_%s", industry, area, city, stype, keyword)
|
|
rediskeyCount := fmt.Sprintf("pcseo_getbidding_count_%s_%s_%s_%s_%s", industry, area, city, stype, keyword)
|
|
rediskeyCount := fmt.Sprintf("pcseo_getbidding_count_%s_%s_%s_%s_%s", industry, area, city, stype, keyword)
|
|
|
|
|
|
- if l, ok := redis.Get("seoCache", rediskey).([]interface{}); ok && l != nil {
|
|
|
|
|
|
+ if l, ok := redis.Get("seoCache", rediskey).([]interface{}); ok && l != nil && false {
|
|
count := redis.GetInt("seoCache", rediskeyCount)
|
|
count := redis.GetInt("seoCache", rediskeyCount)
|
|
return qu.ObjArrToMapArr(l), int64(count), false
|
|
return qu.ObjArrToMapArr(l), int64(count), false
|
|
} else {
|
|
} else {
|
|
@@ -618,75 +618,27 @@ func (this *Tags) GetBidding(industry, area, city, stype, keyword string, reques
|
|
starttime := fmt.Sprint(time.Date(now.Year()-1, now.Month(), now.Day(), now.Hour(), now.Minute(), now.Second(), 0, time.Local).Unix())
|
|
starttime := fmt.Sprint(time.Date(now.Year()-1, now.Month(), now.Day(), now.Hour(), now.Minute(), now.Second(), 0, time.Local).Unix())
|
|
endtime := fmt.Sprint(now.Unix())
|
|
endtime := fmt.Sprint(now.Unix())
|
|
|
|
|
|
- //
|
|
|
|
- query1 := `{"query": {"bool": {"must":[`
|
|
|
|
- query_start := `{"query": {"bool": {"must":[`
|
|
|
|
-
|
|
|
|
- if area != "" {
|
|
|
|
- query1 += `{"term":{"area":"` + area + `"}}`
|
|
|
|
- }
|
|
|
|
- if stype != "" {
|
|
|
|
- if query1 != query_start {
|
|
|
|
- query1 += ","
|
|
|
|
- }
|
|
|
|
- stype = getstype(stype)
|
|
|
|
- query1 += `{"terms":{"subtype":[`
|
|
|
|
- for k, v := range strings.Split(stype, ",") {
|
|
|
|
- if k > 0 {
|
|
|
|
- query1 += `,`
|
|
|
|
- }
|
|
|
|
- query1 += `"` + v + `"`
|
|
|
|
- }
|
|
|
|
- query1 += `]}}`
|
|
|
|
- }
|
|
|
|
- if industry != "" {
|
|
|
|
- if query1 != query_start {
|
|
|
|
- query1 += ","
|
|
|
|
- }
|
|
|
|
- query1 += `{"term":{"s_subscopeclass":"` + industry + `"}}`
|
|
|
|
- }
|
|
|
|
- if city != "" {
|
|
|
|
- if query1 != query_start {
|
|
|
|
- query1 += ","
|
|
|
|
- }
|
|
|
|
- query1 += `{"term":{"city":"` + city + `"}}`
|
|
|
|
- }
|
|
|
|
- if keyword != "" {
|
|
|
|
- if query1 != query_start {
|
|
|
|
- query1 += ","
|
|
|
|
- }
|
|
|
|
- query1 += `{ "bool": {"must": [ { "multi_match": { "query": "` + keyword + `","type": "phrase", "fields": [ "title","detail","purchasing" ]}}]}}`
|
|
|
|
- }
|
|
|
|
- if query1 != query_start {
|
|
|
|
- query1 += ","
|
|
|
|
- }
|
|
|
|
- query1 += `{"range":{"publishtime":{"gte":` + starttime + `,"lt":` + endtime + `}}}`
|
|
|
|
-
|
|
|
|
- query1 += `],"should": [],"minimum_should_match": 0}}}`
|
|
|
|
- log.Println("~~~query1:", query1)
|
|
|
|
- query := getLastNewsQuery(area, fmt.Sprintf("%s_%s", starttime, endtime), stype, industry, city)
|
|
|
|
var datas *[]map[string]interface{}
|
|
var datas *[]map[string]interface{}
|
|
var startPage int
|
|
var startPage int
|
|
|
|
+ var count int64
|
|
currentPage := 5
|
|
currentPage := 5
|
|
- limitcount := qu.IntAllDef(config.Seoconfig["tagsLimitCount"], 50)
|
|
|
|
- count := elastic.Count(INDEX, TYPE, query1)
|
|
|
|
- if count == 0 {
|
|
|
|
- return nil, 0, false
|
|
|
|
- }
|
|
|
|
|
|
+ limitCount := qu.IntAllDef(config.Seoconfig["tagsLimitCount"], 50)
|
|
if keyword == "" {
|
|
if keyword == "" {
|
|
- r := rand.New(rand.NewSource(time.Now().UnixNano()))
|
|
|
|
- startPage = r.Intn(currentPage * limitcount)
|
|
|
|
|
|
+ query := bidsearch.GetSearchQuery("", industry, "1000", "50000", "", "", "", "", bidsearch.GetBidSearchQuery(area, city, fmt.Sprintf("%s_%s", starttime, endtime), stype, "", ""), "", false, seoBidField)
|
|
|
|
+ count = elastic.Count(INDEX, TYPE, query)
|
|
|
|
+ if count == 0 {
|
|
|
|
+ return nil, 0, false
|
|
|
|
+ }
|
|
|
|
+ startPage = rand.New(rand.NewSource(time.Now().UnixNano())).Intn(currentPage * limitCount)
|
|
count1 := qu.IntAll(count)
|
|
count1 := qu.IntAll(count)
|
|
if count1 < startPage || startPage < 0 {
|
|
if count1 < startPage || startPage < 0 {
|
|
startPage = 0
|
|
startPage = 0
|
|
}
|
|
}
|
|
- datas = elastic.GetPage(INDEX, TYPE, query, bidSearch_sort, seoBidField, startPage, limitcount)
|
|
|
|
|
|
+ datas = elastic.GetPage(INDEX, TYPE, query, bidSearch_sort, seoBidField, startPage, limitCount)
|
|
} else {
|
|
} else {
|
|
- log.Println(keyword, area, city, industry)
|
|
|
|
- _, _, datas = bidsearch.GetPcBidSearchData(keyword, area, city, fmt.Sprintf("%s_%s", starttime, endtime), stype, industry, "", "", "", "", "", "", "", 0, true, []string{"title", "detail", "purchasing"}, seoBidField, "", false, false, "", limitcount, "")
|
|
|
|
-
|
|
|
|
- if datas != nil && len(*datas) > limitcount {
|
|
|
|
- *datas = (*datas)[0:limitcount]
|
|
|
|
|
|
+ count, _, datas = bidsearch.GetPcBidSearchData(keyword, area, city, fmt.Sprintf("%s_%s", starttime, endtime), stype, industry, "1000", "50000", "", "", "", "", "", 0, true, []string{"title", "detail", "purchasing"}, seoBidField, "", false, false, "", limitCount, "")
|
|
|
|
+ if datas != nil && len(*datas) > limitCount {
|
|
|
|
+ *datas = (*datas)[0:limitCount]
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if datas != nil && len(*datas) > 0 {
|
|
if datas != nil && len(*datas) > 0 {
|