|
@@ -369,12 +369,11 @@ func getDataExportSql(scd *SieveCondition) string {
|
|
|
appendedShoulds = append(appendedShoulds, fmt.Sprintf(multi_match_new, "\""+vk+"\""))
|
|
|
}
|
|
|
}
|
|
|
- } else if strings.Contains(vv, " ") {
|
|
|
+ } else {
|
|
|
for _, vk := range strings.Split(vv, " ") {
|
|
|
if len(vk) == 0 {
|
|
|
continue
|
|
|
}
|
|
|
-
|
|
|
//单个字 搜索范围 有全文或者附件 无标题 例如:学 虚拟机 detail 搜索的时候加上标题
|
|
|
if scd.Comeinfrom == "supersearchPage" && DetailFileORTitle(selectType) && len([]rune(elastic.ReplaceYH(vk))) == 1 {
|
|
|
queryItem = strings.ReplaceAll(selectType+",title", ",", "\",\"")
|
|
@@ -384,9 +383,6 @@ func getDataExportSql(scd *SieveCondition) string {
|
|
|
appendedShoulds = append(appendedShoulds, fmt.Sprintf(multi_match_new, "\""+vk+"\""))
|
|
|
}
|
|
|
}
|
|
|
- } else {
|
|
|
- appendedShoulds = append(appendedShoulds, fmt.Sprintf(multi_match_new, "\""+vv+"\""))
|
|
|
-
|
|
|
}
|
|
|
// 单个关键词分词后都包含
|
|
|
shoulds = append(shoulds, fmt.Sprintf(query_bool_must_and, strings.Join(appendedShoulds, ","), ""))
|
|
@@ -644,15 +640,17 @@ func GetDataExportSelectReallyCount(bid mg.MongodbSim, biddingName string, ids [
|
|
|
}
|
|
|
|
|
|
func GetDataExportSelectResult(bidding mg.MongodbSim, biddingName string, scd *SieveCondition, dataType string, checkCount int) (*[]map[string]interface{}, error) {
|
|
|
- sess := bidding.GetMgoConn()
|
|
|
- defer bidding.DestoryMongoConn(sess)
|
|
|
- selectMap := map[string]interface{}{
|
|
|
- "_id": 1, "title": 1, "detail": 1, "area": 1, "city": 1, "publishtime": 1, "projectname": 1, "buyer": 1, "s_winner": 1, "bidamount": 1, "subtype": 1, "toptype": 1, "filetext": 1, "purchasing": 1,
|
|
|
- }
|
|
|
+ //sess := bidding.GetMgoConn()
|
|
|
+ //defer bidding.DestoryMongoConn(sess)
|
|
|
+ bidField := `"_id", "title", "detail", "area", "city", "publishtime", "projectname", "buyer", "s_winner", "bidamount", "subtype", "toptype", "filetext", "purchasing"`
|
|
|
+ //selectMap := map[string]interface{}{
|
|
|
+ // "_id": 1, "title": 1, "detail": 1, "area": 1, "city": 1, "publishtime": 1, "projectname": 1, "buyer": 1, "s_winner": 1, "bidamount": 1, "subtype": 1, "toptype": 1, "filetext": 1, "purchasing": 1,
|
|
|
+ //}
|
|
|
if dataType == "2" {
|
|
|
- for _, key := range []string{"href", "projectcode", "buyerperson", "buyertel", "budget", "bidopentime", "agency", "projectscope", "winnerperson", "winnertel", "bidendtime", "district", "signendtime", "buyeraddr"} {
|
|
|
- selectMap[key] = 1
|
|
|
- }
|
|
|
+ bidField = bidField + `", href", "projectcode", "buyerperson", "buyertel", "budget", "bidopentime", "agency", "projectscope", "winnerperson", "winnertel", "bidendtime", "district", "signendtime", "buyeraddr"`
|
|
|
+ //for _, key := range []string{"href", "projectcode", "buyerperson", "buyertel", "budget", "bidopentime", "agency", "projectscope", "winnerperson", "winnertel", "bidendtime", "district", "signendtime", "buyeraddr", "filetext"} {
|
|
|
+ // selectMap[key] = 1
|
|
|
+ //}
|
|
|
}
|
|
|
if checkCount == -1 && len(scd.SelectIds) > 500 {
|
|
|
scd.SelectIds = scd.SelectIds[:500]
|
|
@@ -669,41 +667,54 @@ func GetDataExportSelectResult(bidding mg.MongodbSim, biddingName string, scd *S
|
|
|
wait.Done()
|
|
|
<-pool
|
|
|
}()
|
|
|
- var queryIds []interface{}
|
|
|
- for _, idStr := range arr {
|
|
|
- queryIds = append(queryIds, mg.StringTOBsonId(idStr))
|
|
|
- }
|
|
|
- iter := sess.DB(biddingName).C("bidding").Select(selectMap).Find(map[string]interface{}{"_id": map[string]interface{}{
|
|
|
- "$in": queryIds,
|
|
|
- }}).Iter()
|
|
|
- for m := make(map[string]interface{}); iter.Next(&m); {
|
|
|
- m["_id"] = mg.BsonIdToSId(m["_id"])
|
|
|
- detail, _ := m["detail"].(string)
|
|
|
- if detail != "" {
|
|
|
- m["detail"] = contentfilterReg.ReplaceAllString(detail, "")
|
|
|
- }
|
|
|
- lock.Lock()
|
|
|
- returnLsit = append(returnLsit, m)
|
|
|
- lock.Unlock()
|
|
|
- m = make(map[string]interface{})
|
|
|
- }
|
|
|
- iter_back := sess.DB(biddingName).C("bidding_back").Select(selectMap).Find(map[string]interface{}{"_id": map[string]interface{}{
|
|
|
- "$in": queryIds,
|
|
|
- }}).Iter()
|
|
|
- for m := make(map[string]interface{}); iter_back.Next(&m); {
|
|
|
- m["_id"] = mg.BsonIdToSId(m["_id"])
|
|
|
- detail, _ := m["detail"].(string)
|
|
|
- if detail != "" {
|
|
|
- m["detail"] = contentfilterReg.ReplaceAllString(detail, "")
|
|
|
+ //var queryIds []interface{}
|
|
|
+ //for _, idStr := range arr {
|
|
|
+ // queryIds = append(queryIds, mg.StringTOBsonId(idStr))
|
|
|
+ //}
|
|
|
+ query := fmt.Sprintf(`{"query":{"bool":{"must":[{"terms":{"id":["%s"]}}]}},"_source": [%s],"size":%d}`, strings.Join(arr, "\",\""), bidField, len(arr))
|
|
|
+ data := *elastic.Get(INDEX, TYPE, query)
|
|
|
+ if data != nil && len(data) > 0 {
|
|
|
+ for _, bv := range data {
|
|
|
+ bv["_id"] = mg.BsonIdToSId(bv["_id"])
|
|
|
+ detail, _ := bv["detail"].(string)
|
|
|
+ if detail != "" {
|
|
|
+ bv["detail"] = contentfilterReg.ReplaceAllString(detail, "")
|
|
|
+ }
|
|
|
+ lock.Lock()
|
|
|
+ returnLsit = append(returnLsit, bv)
|
|
|
+ lock.Unlock()
|
|
|
}
|
|
|
- lock.Lock()
|
|
|
- returnLsit = append(returnLsit, m)
|
|
|
- lock.Unlock()
|
|
|
- m = make(map[string]interface{})
|
|
|
}
|
|
|
+ //iter := sess.DB(biddingName).C("bidding").Select(selectMap).Find(map[string]interface{}{"_id": map[string]interface{}{
|
|
|
+ // "$in": queryIds,
|
|
|
+ //}}).Iter()
|
|
|
+ //for m := make(map[string]interface{}); iter.Next(&m); {
|
|
|
+ // m["_id"] = mg.BsonIdToSId(m["_id"])
|
|
|
+ // detail, _ := m["detail"].(string)
|
|
|
+ // if detail != "" {
|
|
|
+ // m["detail"] = contentfilterReg.ReplaceAllString(detail, "")
|
|
|
+ // }
|
|
|
+ // lock.Lock()
|
|
|
+ // returnLsit = append(returnLsit, m)
|
|
|
+ // lock.Unlock()
|
|
|
+ // m = make(map[string]interface{})
|
|
|
+ //}
|
|
|
+ //iter_back := sess.DB(biddingName).C("bidding_back").Select(selectMap).Find(map[string]interface{}{"_id": map[string]interface{}{
|
|
|
+ // "$in": queryIds,
|
|
|
+ //}}).Iter()
|
|
|
+ //for m := make(map[string]interface{}); iter_back.Next(&m); {
|
|
|
+ // m["_id"] = mg.BsonIdToSId(m["_id"])
|
|
|
+ // detail, _ := m["detail"].(string)
|
|
|
+ // if detail != "" {
|
|
|
+ // m["detail"] = contentfilterReg.ReplaceAllString(detail, "")
|
|
|
+ // }
|
|
|
+ // lock.Lock()
|
|
|
+ // returnLsit = append(returnLsit, m)
|
|
|
+ // lock.Unlock()
|
|
|
+ // m = make(map[string]interface{})
|
|
|
+ //}
|
|
|
return nil
|
|
|
}(v)
|
|
|
-
|
|
|
}
|
|
|
wait.Wait()
|
|
|
if len(returnLsit) == checkCount || checkCount == -1 {
|