|
@@ -30,6 +30,7 @@ const (
|
|
|
freeSearchNum = 5 //免费查询数量限制
|
|
|
|
|
|
index, itype = "qyxy", "qyxy"
|
|
|
+ entQuery = `{"query":{"bool":{"must":[%s]}},"_source":["_id","company_name","company_status","legal_person","capital","company_address"]}`
|
|
|
)
|
|
|
|
|
|
var (
|
|
@@ -106,7 +107,7 @@ func (es *EnterpriseSearch) Check() (*EnterpriseSearch, error) {
|
|
|
//return company_name、company_status、legal_person、capital、company_address、id
|
|
|
//返回字段 企业名称、企业状态、法人、注册资本、地址、企业id
|
|
|
func (es *EnterpriseSearch) GetQuerySql() string {
|
|
|
- query := `{"query":{"bool":{"must":[%s]}},"_source":["_id","company_name","company_status","legal_person","capital","company_address"]}`
|
|
|
+
|
|
|
musts := make([]string, 0, 0)
|
|
|
//输入查询
|
|
|
if es.Match != "" { //或关系 仅需满足一个
|
|
@@ -118,10 +119,8 @@ func (es *EnterpriseSearch) GetQuerySql() string {
|
|
|
thisQuery = append(thisQuery, fmt.Sprintf(q, es.Match))
|
|
|
}
|
|
|
}
|
|
|
- } else { //查询全部
|
|
|
- for _, q := range AllMatchType {
|
|
|
- thisQuery = append(thisQuery, fmt.Sprintf(q, es.Match))
|
|
|
- }
|
|
|
+ } else { //默认查询企业名称
|
|
|
+ thisQuery = append(thisQuery, fmt.Sprintf(AllMatchType["A"], es.Match))
|
|
|
}
|
|
|
musts = append(musts, fmt.Sprintf(`{"bool":{"should":[%s],"minimum_should_match": 1}}`, strings.Join(thisQuery, ",")))
|
|
|
}
|
|
@@ -184,7 +183,7 @@ func (es *EnterpriseSearch) GetQuerySql() string {
|
|
|
if es.EntContact != "" && es.IsVip {
|
|
|
musts = append(musts, fmt.Sprintf(`{"term":{"bid_contracttype":"%s"}}`, es.EntContact))
|
|
|
}
|
|
|
- return fmt.Sprintf(query, strings.Join(musts, ","))
|
|
|
+ return fmt.Sprintf(entQuery, strings.Join(musts, ","))
|
|
|
}
|
|
|
|
|
|
//DoQuery 根据EnterpriseSearch参数进行企业相关查询
|