| | |
| | | ) |
| | | |
| | | // 查询底库人员信息 |
| | | func DbPersoninfos( queryindex int, querynums int ) ([]*protomsg.Esinfo, error){ |
| | | func Personinfos( queryIndex int, queryNums int, indexName string, serverIp string, serverPort string, analyServerId string) ([]*protomsg.Esinfo, error){ |
| | | var dbinfos []*protomsg.Esinfo |
| | | point := strconv.Itoa(queryindex) |
| | | number := strconv.Itoa(querynums) |
| | | |
| | | var dbinfoRequest = ` { |
| | | point := strconv.Itoa(queryIndex) |
| | | number := strconv.Itoa(queryNums) |
| | | JsonDSL := "" |
| | | if indexName == "videopersons" { |
| | | JsonDSL = ` { |
| | | "from": ` + point + `, |
| | | "query": { |
| | | "bool": { |
| | | "filter": [ |
| | | { |
| | | "term": { |
| | | "analyServerId": ` + analyServerId + ` |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | }, |
| | | "size":`+ number +`, |
| | | "_source": [ |
| | | "id", |
| | | "faceFeature" |
| | | ] |
| | | }` |
| | | }else { |
| | | JsonDSL = ` { |
| | | "from": ` + point + `, |
| | | "query": { |
| | | "match_all": {} |
| | |
| | | "faceFeature" |
| | | ] |
| | | }` |
| | | |
| | | buf, err := EsReq("POST", "http://192.168.1.182:9200/dbtablepersons/dbpersons/_search",[]byte(dbinfoRequest)) |
| | | } |
| | | buf, err := EsReq("POST", "http://"+serverIp+":"+serverPort+"/"+indexName+"/_search",[]byte(JsonDSL)) |
| | | if err != nil { |
| | | return dbinfos ,errors.New("http request dbtablename info is err!") |
| | | } |
| | |
| | | } |
| | | |
| | | // 根据底库id查询底库信息 |
| | | func Dbtablefosbyid (id []string) ([]protomsg.Dbtable, error) { |
| | | func Dbtablefosbyid (id []string, indexName string, serverIp string, serverPort string) ([]protomsg.Dbtable, error) { |
| | | var dbinfo []protomsg.Dbtable |
| | | dbtableId := strings.Replace(strings.Trim(fmt.Sprint(id), "[]"), " ", "\",\"", -1) |
| | | var dbinfoRequest = ` |
| | |
| | | "bool": { |
| | | "filter": [{ |
| | | "terms": { |
| | | "_id": [ |
| | | "id": [ |
| | | "`+ dbtableId +`" |
| | | ] |
| | | } |
| | |
| | | } |
| | | } |
| | | ` |
| | | buf, err := EsReq("POST", "http://192.168.1.182:9200/dbtables/_search",[]byte(dbinfoRequest)) |
| | | buf, err := EsReq("POST", "http://"+serverIp+":"+serverPort+"/"+indexName+"/_search",[]byte(dbinfoRequest)) |
| | | if err != nil { |
| | | return dbinfo, err |
| | | } |
| | |
| | | } |
| | | |
| | | // 根据底库人员id查询底库人员信息 |
| | | func Dbpersoninfosbyid (id []string) ([]protomsg.Dbperson, error) { |
| | | func Dbpersoninfosbyid (id []string, indexName string, serverIp string, serverPort string) ([]protomsg.Dbperson, error) { |
| | | var dbinfo []protomsg.Dbperson |
| | | dbtablePersonId := strings.Replace(strings.Trim(fmt.Sprint(id), "[]"), " ", "\",\"", -1) |
| | | var dbinfoRequest = ` |
| | |
| | | "bool": { |
| | | "filter": [{ |
| | | "terms": { |
| | | "_id": [ |
| | | "id": [ |
| | | "`+ dbtablePersonId +`" |
| | | ] |
| | | } |
| | |
| | | } |
| | | } |
| | | ` |
| | | buf, err := EsReq("POST", "http://192.168.1.182:9200/dbtablepersons/_search",[]byte(dbinfoRequest)) |
| | | buf, err := EsReq("POST", "http://"+serverIp+":"+serverPort+"/"+indexName+"/_search",[]byte(dbinfoRequest)) |
| | | if err != nil { |
| | | return dbinfo, err |
| | | } |
| | |
| | | } |
| | | |
| | | // 根据tableid 查询tablename |
| | | func Dbtablename(tableid string ) (tablename string, err error) { |
| | | func Dbtablename(tableid string, indexName string, serverIp string, serverPort string) (tablename string, err error) { |
| | | var dbinfotable =` { |
| | | "query": { |
| | | "bool": { |
| | |
| | | ] |
| | | } |
| | | ` |
| | | buf, err := EsReq("POST", "http://192.168.1.182:9200/dbtables/_search",[]byte(dbinfotable)) |
| | | buf, err := EsReq("POST", "http://"+serverIp+":"+serverPort+"/"+indexName+"/_search",[]byte(dbinfotable)) |
| | | if err != nil { |
| | | return "" ,errors.New("http request dbtablename info is err!") |
| | | } |