|
@@ -10,6 +10,7 @@ import (
|
|
|
"regexp"
|
|
|
"strings"
|
|
|
"time"
|
|
|
+ sql "sqlmodel"
|
|
|
|
|
|
"gopkg.in/mgo.v2/bson"
|
|
|
)
|
|
@@ -190,6 +191,139 @@ func UtilEsFind(tags map[string]interface{}) (error, int64) {
|
|
|
return err, 0
|
|
|
}
|
|
|
}
|
|
|
+//客户规则
|
|
|
+func UtilEsFind1(tags map[string]interface{}) (error, int64) {
|
|
|
+ defer util.Catch()
|
|
|
+ sdataid := util.ObjToString(tags["s_dataid"])
|
|
|
+ esquery := util.ObjToString(tags["s_esquery"])
|
|
|
+ if len(esquery) < 1 || len(sdataid) < 1 {
|
|
|
+ return errors.New("s_esquery or s_dataid no found"), 0
|
|
|
+ }
|
|
|
+ i_maxnum := util.Int64All(tags["i_maxnum"])
|
|
|
+ if i_maxnum <= 0 {
|
|
|
+ i_maxnum = 100
|
|
|
+ }
|
|
|
+ maths := make([]map[string]string, 0)
|
|
|
+ if orules, ok := tags["o_rules"].([]interface{}); ok {
|
|
|
+ for _, v := range orules {
|
|
|
+ orule, _ := v.(map[string]interface{})
|
|
|
+ maths = append(maths, map[string]string{
|
|
|
+ "s_matchkey": util.ObjToString(orule["s_matchkey"]),
|
|
|
+ "s_keymatch": util.ObjToString(orule["s_keymatch"]),
|
|
|
+ })
|
|
|
+ }
|
|
|
+ } else if orules, ok := tags["o_rules"].([]map[string]interface{}); ok {
|
|
|
+ for _, v := range orules {
|
|
|
+ maths = append(maths, map[string]string{
|
|
|
+ "s_matchkey": util.ObjToString(v["s_matchkey"]),
|
|
|
+ "s_keymatch": util.ObjToString(v["s_keymatch"]),
|
|
|
+ })
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return errors.New("o_rules no found"), 0
|
|
|
+ }
|
|
|
+ client := elastic.GetEsConn()
|
|
|
+ defer elastic.DestoryEsConn(client)
|
|
|
+ esquery = esquery[:len(esquery)-1] + `,"size":` + fmt.Sprintf("%d", i_maxnum) + `}`
|
|
|
+ searchResult, err := client.Search(EsIndex).Source(esquery).Do()
|
|
|
+ if err == nil && searchResult.Hits != nil {
|
|
|
+ datas := make([]map[string]interface{}, 0)
|
|
|
+ util.Debug("es查询到的数量:", searchResult.Hits.TotalHits)
|
|
|
+ for _, v := range searchResult.Hits.Hits {
|
|
|
+ item := make(map[string]interface{})
|
|
|
+ if json.Unmarshal(*v.Source, &item) == nil {
|
|
|
+ delete(item,"_id")
|
|
|
+ item["info_id"] = v.Id
|
|
|
+ item["s_dataid"] = sdataid
|
|
|
+ item["s_jyhref"] = fmt.Sprintf(Url, util.CommonEncodeArticle("content", v.Id))
|
|
|
+ item["i_createtime"] = time.Now().Unix()
|
|
|
+ var d *DFA = &DFA{}
|
|
|
+ var analyKeys []string //找到的关键词
|
|
|
+ var matchType []string //匹配方式
|
|
|
+ for _, math := range maths {
|
|
|
+ fileds := strsToArr(math["s_keymatch"], "field")
|
|
|
+ d.AddWord(strings.Split(math["s_matchkey"], ",")...)
|
|
|
+ mkMap := make(map[string]interface{})
|
|
|
+ tmpMap := make(map[string]interface{})
|
|
|
+ for _, mk := range strings.Split(math["s_matchkey"], ",") {
|
|
|
+ if strings.Contains(mk, "&&") {
|
|
|
+ arr := strings.Split(mk, "&&")
|
|
|
+ for _, s := range arr{
|
|
|
+ if s != "" {
|
|
|
+ tmpMap[s] = mk
|
|
|
+ if b, _ := regexp.MatchString("[A-Z]", s); b {
|
|
|
+ mkMap[strings.ToLower(s)] = s
|
|
|
+ d.AddWord(strings.ToLower(s))
|
|
|
+ }else {
|
|
|
+ d.AddWord(s)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ if b, _ := regexp.MatchString("[A-Z]", mk); b {
|
|
|
+ mkMap[strings.ToLower(mk)] = mk
|
|
|
+ d.AddWord(strings.ToLower(mk))
|
|
|
+ }else {
|
|
|
+ d.AddWord(mk)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for _, filed := range fileds {
|
|
|
+ filed1 := strings.ToLower(util.ObjToString(item[filed]))
|
|
|
+ ddds := d.Analy(filed1)
|
|
|
+ analyKeys = append(analyKeys, ddds...)
|
|
|
+ }
|
|
|
+ if len(analyKeys) > 0 {
|
|
|
+ matchType = append(matchType, strings.Join(fileds, ","))
|
|
|
+ for k, v := range analyKeys{
|
|
|
+ if tmpMap[v] != "" && tmpMap[v] != nil {
|
|
|
+ analyKeys[k] = util.ObjToString(tmpMap[v])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for _, v1 := range analyKeys{
|
|
|
+ if mkMap[v1] != "" && mkMap[v1] != nil {
|
|
|
+ analyKeys = deleteSlice(analyKeys, v1)
|
|
|
+ analyKeys = append(analyKeys, util.ObjToString(mkMap[v1]))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ d.Clear()
|
|
|
+ }
|
|
|
+ //去重
|
|
|
+ ssavekey := make(map[string]bool)
|
|
|
+ for _, v := range analyKeys {
|
|
|
+ ssavekey[v] = true
|
|
|
+ }
|
|
|
+ ssavekeys := []string{}
|
|
|
+ for k := range ssavekey {
|
|
|
+ ssavekeys = append(ssavekeys, k)
|
|
|
+ }
|
|
|
+ item["s_matchkey"] = strings.Join(ssavekeys, ",")
|
|
|
+ item["s_matchtype"] = strings.Join(matchType, ",")
|
|
|
+ findwinner := strings.TrimSpace(util.ObjToString(item["winner"]))
|
|
|
+ if findwinner != "" {
|
|
|
+ finddata, _ := MgoEn.FindOne(MgoEnC, bson.M{"company_name": findwinner})
|
|
|
+ if finddata != nil && (*finddata) != nil {
|
|
|
+ item["legal_person"] = util.ObjToString((*finddata)["legal_person"])
|
|
|
+ item["company_email"] = util.ObjToString((*finddata)["company_email"])
|
|
|
+ item["company_phone"] = util.ObjToString((*finddata)["company_phone"])
|
|
|
+ item["qyk"] = finddata
|
|
|
+ }
|
|
|
+ }
|
|
|
+ datas = append(datas, item)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Mgo.Update("cuser", bson.M{"_id": tags["_id"]}, bson.M{
|
|
|
+ "$set": bson.M{
|
|
|
+ "i_estotal": searchResult.Hits.TotalHits,
|
|
|
+ }}, false, false)
|
|
|
+ count := searchResult.Hits.TotalHits
|
|
|
+ return UtilEsSaveData(sdataid, &datas), count
|
|
|
+ } else {
|
|
|
+ util.Debug(err)
|
|
|
+ return err, 0
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
func Utiltags(tag map[string]interface{}) string {
|
|
|
defer util.Catch()
|
|
@@ -199,14 +333,14 @@ func Utiltags(tag map[string]interface{}) string {
|
|
|
if err != nil {
|
|
|
return "json err:" + err.Error()
|
|
|
}
|
|
|
- QueryObjecct := models.QueryObjecct{}
|
|
|
- ffBoolObject := models.BoolObject{}
|
|
|
- adsBoolObect := models.NewEsObject{}
|
|
|
+ QueryObjecct := sql.QueryObjecct{}
|
|
|
+ ffBoolObject := sql.BoolObject{}
|
|
|
+ adsBoolObect := sql.NewEsObject{}
|
|
|
if tab.Sarea != "" {
|
|
|
- adsBoolObect.Bool.Should = append(adsBoolObect.Bool.Should, models.AreaCityDistrictMust{AreaCityDistrict: &models.AreaCityDistrict{Area: strings.Split(tab.Sarea, ",")}})
|
|
|
+ adsBoolObect.Bool.Should = append(adsBoolObect.Bool.Should, sql.AreaCityDistrictMust{AreaCityDistrict: &sql.AreaCityDistrict{Area: strings.Split(tab.Sarea, ",")}})
|
|
|
}
|
|
|
if tab.Scity != "" {
|
|
|
- adsBoolObect.Bool.Should = append(adsBoolObect.Bool.Should, models.AreaCityDistrictMust{AreaCityDistrict: &models.AreaCityDistrict{City: strings.Split(tab.Scity, ",")}})
|
|
|
+ adsBoolObect.Bool.Should = append(adsBoolObect.Bool.Should, sql.AreaCityDistrictMust{AreaCityDistrict: &sql.AreaCityDistrict{City: strings.Split(tab.Scity, ",")}})
|
|
|
}
|
|
|
if tab.Sdistrict != "" {
|
|
|
//城市——区县
|
|
@@ -215,80 +349,80 @@ func Utiltags(tag map[string]interface{}) string {
|
|
|
for _, v := range cityds{
|
|
|
ds = append(ds, strings.Split(v, "-")[1])
|
|
|
}
|
|
|
- adsBoolObect.Bool.Should = append(adsBoolObect.Bool.Should, models.AreaCityDistrictMust{AreaCityDistrict: &models.AreaCityDistrict{District: ds}})
|
|
|
+ adsBoolObect.Bool.Should = append(adsBoolObect.Bool.Should, sql.AreaCityDistrictMust{AreaCityDistrict: &sql.AreaCityDistrict{District: ds}})
|
|
|
}
|
|
|
if len(adsBoolObect.Bool.Should) > 0 {
|
|
|
ffBoolObject.Must = append(ffBoolObject.Must, adsBoolObect)
|
|
|
}
|
|
|
if tab.Stoptype != "" || tab.Ssubtype != "" {
|
|
|
if len(tab.Stoptype) > 0 {
|
|
|
- toptypeSubtype := models.ToptypeSubtype{}
|
|
|
+ toptypeSubtype := sql.ToptypeSubtype{}
|
|
|
toptypeSubtype.Toptype = strings.Split(tab.Stoptype, ",")
|
|
|
- ffBoolObject.Must = append(ffBoolObject.Must, models.ToptypeSubtypeMust{&toptypeSubtype})
|
|
|
+ ffBoolObject.Must = append(ffBoolObject.Must, sql.ToptypeSubtypeMust{&toptypeSubtype})
|
|
|
}
|
|
|
if len(tab.Ssubtype) > 0 {
|
|
|
- toptypeSubtype := models.ToptypeSubtype{}
|
|
|
+ toptypeSubtype := sql.ToptypeSubtype{}
|
|
|
toptypeSubtype.Subtype = strings.Split(tab.Ssubtype, ",")
|
|
|
- ffBoolObject.Must = append(ffBoolObject.Must, models.ToptypeSubtypeMust{&toptypeSubtype})
|
|
|
+ ffBoolObject.Must = append(ffBoolObject.Must, sql.ToptypeSubtypeMust{&toptypeSubtype})
|
|
|
}
|
|
|
}
|
|
|
if tab.Istarttime > 0 && tab.Iendtime > 0 {
|
|
|
- ffBoolObject.Must = append(ffBoolObject.Must, models.PublishtimeMust{PublishtimeObject: &models.PublishtimeObject{Publishtime: &models.Publishtime{
|
|
|
+ ffBoolObject.Must = append(ffBoolObject.Must, sql.PublishtimeMust{PublishtimeObject: &sql.PublishtimeObject{Publishtime: &sql.Publishtime{
|
|
|
Gte: tab.Istarttime,
|
|
|
Lt: tab.Iendtime,
|
|
|
}}})
|
|
|
}else if tab.Istarttime > 0 {
|
|
|
- ffBoolObject.Must = append(ffBoolObject.Must, models.PublishtimeMust{PublishtimeObject: &models.PublishtimeObject{Publishtime1: &models.Publishtime1{
|
|
|
+ ffBoolObject.Must = append(ffBoolObject.Must, sql.PublishtimeMust{PublishtimeObject: &sql.PublishtimeObject{Publishtime1: &sql.Publishtime1{
|
|
|
Gte: tab.Istarttime,
|
|
|
}}})
|
|
|
}else if tab.Iendtime > 0 {
|
|
|
- ffBoolObject.Must = append(ffBoolObject.Must, models.PublishtimeMust{PublishtimeObject: &models.PublishtimeObject{Publishtime2: &models.Publishtime2{
|
|
|
+ ffBoolObject.Must = append(ffBoolObject.Must, sql.PublishtimeMust{PublishtimeObject: &sql.PublishtimeObject{Publishtime2: &sql.Publishtime2{
|
|
|
Lt: tab.Iendtime,
|
|
|
}}})
|
|
|
}
|
|
|
if tab.Sbudget != "" {
|
|
|
if strings.Contains(tab.Sbudget, "大于") && strings.Contains(tab.Sbudget, "小于") {
|
|
|
arr := strings.Split(tab.Sbudget, ",")
|
|
|
- limit := &models.BudgetOrBidamount{
|
|
|
+ limit := &sql.BudgetOrBidamount{
|
|
|
Gte: util.Float64All(strings.Replace(arr[0], "大于", "", -1)),
|
|
|
Lt: util.Float64All(strings.Replace(arr[1], "小于", "", -1)),
|
|
|
}
|
|
|
- ffBoolObject.Must = append(ffBoolObject.Must, models.BudgetMust{BudgetObj: &models.BudgetObj{Budget: limit}})
|
|
|
+ ffBoolObject.Must = append(ffBoolObject.Must, sql.BudgetMust{BudgetObj: &sql.BudgetObj{Budget: limit}})
|
|
|
}else if strings.Contains(tab.Sbudget, "大于") {
|
|
|
- limit := &models.BudgetOrBidamount{
|
|
|
+ limit := &sql.BudgetOrBidamount{
|
|
|
Gte: util.Float64All(strings.Replace(tab.Sbudget, "大于", "", -1)),
|
|
|
}
|
|
|
- ffBoolObject.Must = append(ffBoolObject.Must, models.BudgetMust{BudgetObj: &models.BudgetObj{Budget: limit}})
|
|
|
+ ffBoolObject.Must = append(ffBoolObject.Must, sql.BudgetMust{BudgetObj: &sql.BudgetObj{Budget: limit}})
|
|
|
}else if strings.Contains(tab.Sbudget, "小于") {
|
|
|
- limit := &models.BudgetOrBidamount{
|
|
|
+ limit := &sql.BudgetOrBidamount{
|
|
|
Lt: util.Float64All(strings.Replace(tab.Sbudget, "小于", "", -1)),
|
|
|
}
|
|
|
- ffBoolObject.Must = append(ffBoolObject.Must, models.BudgetMust{BudgetObj: &models.BudgetObj{Budget: limit}})
|
|
|
+ ffBoolObject.Must = append(ffBoolObject.Must, sql.BudgetMust{BudgetObj: &sql.BudgetObj{Budget: limit}})
|
|
|
}
|
|
|
}
|
|
|
if tab.Sbidamount != "" {
|
|
|
if strings.Contains(tab.Sbidamount, "大于") && strings.Contains(tab.Sbidamount, "小于") {
|
|
|
arr := strings.Split(tab.Sbidamount, ",")
|
|
|
- limit := &models.BudgetOrBidamount{
|
|
|
+ limit := &sql.BudgetOrBidamount{
|
|
|
Gte: util.Float64All(strings.Replace(arr[0], "大于", "", -1)),
|
|
|
Lt: util.Float64All(strings.Replace(arr[1], "小于", "", -1)),
|
|
|
}
|
|
|
- ffBoolObject.Must = append(ffBoolObject.Must, models.BidamountMust{BidamountObj: &models.BidamountObj{Bidamount: limit}})
|
|
|
+ ffBoolObject.Must = append(ffBoolObject.Must, sql.BidamountMust{BidamountObj: &sql.BidamountObj{Bidamount: limit}})
|
|
|
}else if strings.Contains(tab.Sbidamount, "大于") {
|
|
|
- limit := &models.BudgetOrBidamount{
|
|
|
+ limit := &sql.BudgetOrBidamount{
|
|
|
Gte: util.Float64All(strings.Replace(tab.Sbidamount, "大于", "", -1)),
|
|
|
}
|
|
|
- ffBoolObject.Must = append(ffBoolObject.Must, models.BidamountMust{BidamountObj: &models.BidamountObj{Bidamount: limit}})
|
|
|
+ ffBoolObject.Must = append(ffBoolObject.Must, sql.BidamountMust{BidamountObj: &sql.BidamountObj{Bidamount: limit}})
|
|
|
}else if strings.Contains(tab.Sbidamount, "小于") {
|
|
|
- limit := &models.BudgetOrBidamount{
|
|
|
+ limit := &sql.BudgetOrBidamount{
|
|
|
Lt: util.Float64All(strings.Replace(tab.Sbidamount, "小于", "", -1)),
|
|
|
}
|
|
|
- ffBoolObject.Must = append(ffBoolObject.Must, models.BidamountMust{BidamountObj: &models.BidamountObj{Bidamount: limit}})
|
|
|
+ ffBoolObject.Must = append(ffBoolObject.Must, sql.BidamountMust{BidamountObj: &sql.BidamountObj{Bidamount: limit}})
|
|
|
}
|
|
|
}
|
|
|
if tab.Sglobalbuyerclass != "" {
|
|
|
if len(tab.Sglobalbuyerclass) > 0 {
|
|
|
- buyerclass := models.BuyerclassObject{
|
|
|
+ buyerclass := sql.BuyerclassObject{
|
|
|
Terms: struct {
|
|
|
Buyerclass []string `json:"buyerclass,omitempty"`
|
|
|
}{
|
|
@@ -300,21 +434,21 @@ func Utiltags(tag map[string]interface{}) string {
|
|
|
}
|
|
|
if tab.Sglobaltopscopeclass != "" || tab.Sglobalsubscopeclass != "" {
|
|
|
if len(tab.Sglobaltopscopeclass) > 0 {
|
|
|
- topScopeclass := models.Scopeclass{}
|
|
|
+ topScopeclass := sql.Scopeclass{}
|
|
|
topScopeclass.Globaltopscopeclass = strings.Split(tab.Sglobaltopscopeclass, ",")
|
|
|
- ffBoolObject.Must = append(ffBoolObject.Must, models.ScopeclassMust{&topScopeclass})
|
|
|
+ ffBoolObject.Must = append(ffBoolObject.Must, sql.ScopeclassMust{&topScopeclass})
|
|
|
}else if len(tab.Sglobalsubscopeclass) > 0 {
|
|
|
- subScopeclass := models.Scopeclass{}
|
|
|
+ subScopeclass := sql.Scopeclass{}
|
|
|
subScopeclass.Globalsubscopeclass = strings.Split(tab.Sglobalsubscopeclass, ",")
|
|
|
- ffBoolObject.Must = append(ffBoolObject.Must, models.ScopeclassMust{&subScopeclass})
|
|
|
+ ffBoolObject.Must = append(ffBoolObject.Must, sql.ScopeclassMust{&subScopeclass})
|
|
|
}
|
|
|
}
|
|
|
- fqBoolObject := models.BoolObject{}
|
|
|
+ fqBoolObject := sql.BoolObject{}
|
|
|
if len(tab.Sexistfields) > 0 {
|
|
|
tmpsfields := strings.Split(tab.Sexistfields, ",")
|
|
|
for _, v := range tmpsfields {
|
|
|
- fqBoolObject.MustNot = append(fqBoolObject.MustNot, models.ExistfieldsObjectMust{
|
|
|
- ExistfieldsObject: &models.ExistfieldsObject{Filter: struct {
|
|
|
+ fqBoolObject.MustNot = append(fqBoolObject.MustNot, sql.ExistfieldsObjectMust{
|
|
|
+ ExistfieldsObject: &sql.ExistfieldsObject{Filter: struct {
|
|
|
Missing struct {
|
|
|
Field string `json:"field,omitempty"`
|
|
|
} `json:"missing,omitempty"`
|
|
@@ -327,7 +461,7 @@ func Utiltags(tag map[string]interface{}) string {
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
- newEsObject := models.NewEsObject{}
|
|
|
+ newEsObject := sql.NewEsObject{}
|
|
|
if tab.Sglobaladdkey != "" && tab.Sglobaladdkeymatch != "" {
|
|
|
if tmps := strsToArr(tab.Sglobaladdkeymatch, "str"); tmps != nil {
|
|
|
newEsObject = method1(newEsObject, tab.Sglobaladdkey, tab.Sglobaladdkeymatch, tmps)
|
|
@@ -337,7 +471,7 @@ func Utiltags(tag map[string]interface{}) string {
|
|
|
fqBoolObject.Must = append(fqBoolObject.Must, newEsObject)
|
|
|
}
|
|
|
|
|
|
- nots := models.NewEsObject{}
|
|
|
+ nots := sql.NewEsObject{}
|
|
|
if tab.Sglobalnotkey != "" && tab.Sglobalnotkeymatch != "" {
|
|
|
if tmps := strsToArr(tab.Sglobalnotkeymatch, "str"); tmps != nil {
|
|
|
nots = method1(nots, tab.Sglobalnotkey, tab.Sglobalnotkeymatch, tmps)
|
|
@@ -346,18 +480,18 @@ func Utiltags(tag map[string]interface{}) string {
|
|
|
if len(nots.Bool.Should) > 0 {
|
|
|
fqBoolObject.MustNot = append(fqBoolObject.MustNot, nots)
|
|
|
}
|
|
|
- torules := models.BoolObject{}
|
|
|
+ torules := sql.BoolObject{}
|
|
|
for _, v := range tab.Orules {
|
|
|
- tmpses := models.NewEsObject{}
|
|
|
+ tmpses := sql.NewEsObject{}
|
|
|
if skeymatchs := strsToArr(v.Skeymatch, "str"); skeymatchs != nil {
|
|
|
- tmpnewEsObject := models.NewEsObject{}
|
|
|
+ tmpnewEsObject := sql.NewEsObject{}
|
|
|
tmpnewEsObject = method1(tmpnewEsObject, v.Smatchkey, v.Skeymatch, skeymatchs)
|
|
|
if len(tmpnewEsObject.Bool.Should) > 0 || len(tmpnewEsObject.Bool.Must) > 0 || len(tmpnewEsObject.Bool.MustNot) > 0 {
|
|
|
tmpses.Bool.Must = append(tmpses.Bool.Must, tmpnewEsObject)
|
|
|
}
|
|
|
}
|
|
|
if saddkeymatchs := strsToArr(v.Saddkeymatch, "str"); saddkeymatchs != nil {
|
|
|
- addkeyarr := models.NewEsObject{}
|
|
|
+ addkeyarr := sql.NewEsObject{}
|
|
|
addkeyarr = method1(addkeyarr, v.Saddkey, v.Saddkeymatch, saddkeymatchs)
|
|
|
if len(addkeyarr.Bool.Should) > 0 {
|
|
|
tmpses.Bool.Must = append(tmpses.Bool.Must, addkeyarr)
|
|
@@ -368,7 +502,7 @@ func Utiltags(tag map[string]interface{}) string {
|
|
|
}
|
|
|
if len(v.Stopscopeclass) > 0 {
|
|
|
sArr := strings.Split(v.Stopscopeclass, ",")
|
|
|
- tmpses.Bool.Must = append(tmpses.Bool.Must, models.TopscopeclassObject{
|
|
|
+ tmpses.Bool.Must = append(tmpses.Bool.Must, sql.TopscopeclassObject{
|
|
|
Terms: struct {
|
|
|
Topscopeclass []string `json:"s_topscopeclass,omitempty"`
|
|
|
}{
|
|
@@ -376,7 +510,7 @@ func Utiltags(tag map[string]interface{}) string {
|
|
|
},
|
|
|
})
|
|
|
}else if len(v.Ssubscopeclass) > 0 {
|
|
|
- tmpses.Bool.Must = append(tmpses.Bool.Must, models.SubscopeclassObject{
|
|
|
+ tmpses.Bool.Must = append(tmpses.Bool.Must, sql.SubscopeclassObject{
|
|
|
Terms: struct {
|
|
|
Subscopeclass []string `json:"s_subscopeclass,omitempty"`
|
|
|
}{
|
|
@@ -385,7 +519,7 @@ func Utiltags(tag map[string]interface{}) string {
|
|
|
})
|
|
|
}
|
|
|
if len(v.Sbuyerclass) > 0 {
|
|
|
- tmpses.Bool.Must = append(tmpses.Bool.Must, models.BuyerclassObject{
|
|
|
+ tmpses.Bool.Must = append(tmpses.Bool.Must, sql.BuyerclassObject{
|
|
|
Terms: struct {
|
|
|
Buyerclass []string `json:"buyerclass,omitempty"`
|
|
|
}{
|
|
@@ -396,11 +530,11 @@ func Utiltags(tag map[string]interface{}) string {
|
|
|
torules.Should = append(torules.Should, tmpses)
|
|
|
}
|
|
|
if len(ffBoolObject.Must) > 0 || len(ffBoolObject.MustNot) > 0 || len(ffBoolObject.Should) > 0 {
|
|
|
- QueryObjecct.Filtered.Filter = &models.Filter{}
|
|
|
+ QueryObjecct.Filtered.Filter = &sql.Filter{}
|
|
|
QueryObjecct.Filtered.Filter.Bool = &ffBoolObject
|
|
|
}
|
|
|
if len(fqBoolObject.Must) > 0 || len(fqBoolObject.MustNot) > 0 || len(fqBoolObject.Should) > 0 {
|
|
|
- QueryObjecct.Filtered.Query = &models.Query{}
|
|
|
+ QueryObjecct.Filtered.Query = &sql.Query{}
|
|
|
QueryObjecct.Filtered.Query.Bool = &fqBoolObject
|
|
|
if len(torules.Should) > 0 {
|
|
|
QueryObjecct.Filtered.Query.Bool.Must = append(QueryObjecct.Filtered.Query.Bool.Must, map[string]interface{}{
|
|
@@ -409,7 +543,7 @@ func Utiltags(tag map[string]interface{}) string {
|
|
|
}
|
|
|
}else if len(torules.Should) > 0 {
|
|
|
if QueryObjecct.Filtered.Query == nil{
|
|
|
- QueryObjecct.Filtered.Query = &models.Query{}
|
|
|
+ QueryObjecct.Filtered.Query = &sql.Query{}
|
|
|
QueryObjecct.Filtered.Query.Bool = &fqBoolObject
|
|
|
}
|
|
|
QueryObjecct.Filtered.Query.Bool.Must = append(QueryObjecct.Filtered.Query.Bool.Must, map[string]interface{}{
|
|
@@ -486,7 +620,7 @@ func init() {
|
|
|
EsType = util.ObjToString(Sysconfig["elasticsearch_type"])
|
|
|
}
|
|
|
|
|
|
-func method1(newEsObject models.NewEsObject, keyword, keymatch string, tmps []string) models.NewEsObject {
|
|
|
+func method1(newEsObject sql.NewEsObject, keyword, keymatch string, tmps []string) sql.NewEsObject {
|
|
|
for _, vv := range strings.Split(keyword, ",") {
|
|
|
if vv == "" {
|
|
|
continue
|
|
@@ -500,24 +634,24 @@ func method1(newEsObject models.NewEsObject, keyword, keymatch string, tmps []st
|
|
|
strs = ".*" + vv + ".*"
|
|
|
}
|
|
|
if tmps[0] == "buyer" {
|
|
|
- newEsObject.Bool.Should = append(newEsObject.Bool.Should, models.Regular{
|
|
|
- Regexp1: &models.Regular_Buyer{Buyer: strs},
|
|
|
+ newEsObject.Bool.Should = append(newEsObject.Bool.Should, sql.Regular{
|
|
|
+ Regexp1: &sql.Regular_Buyer{Buyer: strs},
|
|
|
})
|
|
|
}else if tmps[0] == "s_winner" {
|
|
|
- newEsObject.Bool.Should = append(newEsObject.Bool.Should, models.Regular{
|
|
|
- Regexp2: &models.Regular_winner{Winner: strs},
|
|
|
+ newEsObject.Bool.Should = append(newEsObject.Bool.Should, sql.Regular{
|
|
|
+ Regexp2: &sql.Regular_winner{Winner: strs},
|
|
|
})
|
|
|
}
|
|
|
}else {
|
|
|
addkeylines := strings.Split(vv, "&&")
|
|
|
if len(addkeylines) > 1 {
|
|
|
- addkeyline := models.NewEsObject{}
|
|
|
+ addkeyline := sql.NewEsObject{}
|
|
|
for _, vvv := range addkeylines {
|
|
|
if vvv == "" {
|
|
|
continue
|
|
|
}
|
|
|
- addkeyline.Bool.Must = append(addkeyline.Bool.Must, models.ShouldObj{
|
|
|
- MultiMatch: &models.MultiMatch{
|
|
|
+ addkeyline.Bool.Must = append(addkeyline.Bool.Must, sql.ShouldObj{
|
|
|
+ MultiMatch: &sql.MultiMatch{
|
|
|
Query: vvv,
|
|
|
Type: MultiMatchType,
|
|
|
Fields: tmps,
|
|
@@ -528,8 +662,8 @@ func method1(newEsObject models.NewEsObject, keyword, keymatch string, tmps []st
|
|
|
newEsObject.Bool.Should = append(newEsObject.Bool.Should, addkeyline)
|
|
|
}
|
|
|
} else {
|
|
|
- newEsObject.Bool.Should = append(newEsObject.Bool.Should, models.ShouldObj{
|
|
|
- MultiMatch: &models.MultiMatch{
|
|
|
+ newEsObject.Bool.Should = append(newEsObject.Bool.Should, sql.ShouldObj{
|
|
|
+ MultiMatch: &sql.MultiMatch{
|
|
|
Query: vv,
|
|
|
Type: MultiMatchType,
|
|
|
Fields: tmps,
|
|
@@ -541,7 +675,7 @@ func method1(newEsObject models.NewEsObject, keyword, keymatch string, tmps []st
|
|
|
return newEsObject
|
|
|
}
|
|
|
|
|
|
-func method2(newEsObject models.NewEsObject, keyword, keymatch string, tmps []string) models.NewEsObject {
|
|
|
+func method2(newEsObject sql.NewEsObject, keyword, keymatch string, tmps []string) sql.NewEsObject {
|
|
|
for _, vv := range strings.Split(keyword, ",") {
|
|
|
if vv == "" {
|
|
|
continue
|
|
@@ -555,24 +689,24 @@ func method2(newEsObject models.NewEsObject, keyword, keymatch string, tmps []st
|
|
|
strs = ".*" + vv + ".*"
|
|
|
}
|
|
|
if tmps[0] == "buyer" {
|
|
|
- newEsObject.Bool.MustNot = append(newEsObject.Bool.MustNot, models.Regular{
|
|
|
- Regexp1: &models.Regular_Buyer{Buyer: strs},
|
|
|
+ newEsObject.Bool.MustNot = append(newEsObject.Bool.MustNot, sql.Regular{
|
|
|
+ Regexp1: &sql.Regular_Buyer{Buyer: strs},
|
|
|
})
|
|
|
}else if tmps[0] == "s_winner" {
|
|
|
- newEsObject.Bool.MustNot = append(newEsObject.Bool.MustNot, models.Regular{
|
|
|
- Regexp2: &models.Regular_winner{Winner: strs},
|
|
|
+ newEsObject.Bool.MustNot = append(newEsObject.Bool.MustNot, sql.Regular{
|
|
|
+ Regexp2: &sql.Regular_winner{Winner: strs},
|
|
|
})
|
|
|
}
|
|
|
}else {
|
|
|
addkeylines := strings.Split(vv, "&&")
|
|
|
if len(addkeylines) > 1 {
|
|
|
- addkeyline := models.NewEsObject{}
|
|
|
+ addkeyline := sql.NewEsObject{}
|
|
|
for _, vvv := range addkeylines {
|
|
|
if vvv == "" {
|
|
|
continue
|
|
|
}
|
|
|
- addkeyline.Bool.Must = append(addkeyline.Bool.Must, models.ShouldObj{
|
|
|
- MultiMatch: &models.MultiMatch{
|
|
|
+ addkeyline.Bool.Must = append(addkeyline.Bool.Must, sql.ShouldObj{
|
|
|
+ MultiMatch: &sql.MultiMatch{
|
|
|
Query: vvv,
|
|
|
Type: MultiMatchType,
|
|
|
Fields: tmps,
|
|
@@ -583,8 +717,8 @@ func method2(newEsObject models.NewEsObject, keyword, keymatch string, tmps []st
|
|
|
newEsObject.Bool.MustNot = append(newEsObject.Bool.MustNot, addkeyline)
|
|
|
}
|
|
|
} else {
|
|
|
- newEsObject.Bool.MustNot = append(newEsObject.Bool.MustNot, models.ShouldObj{
|
|
|
- MultiMatch: &models.MultiMatch{
|
|
|
+ newEsObject.Bool.MustNot = append(newEsObject.Bool.MustNot, sql.ShouldObj{
|
|
|
+ MultiMatch: &sql.MultiMatch{
|
|
|
Query: vv,
|
|
|
Type: MultiMatchType,
|
|
|
Fields: tmps,
|