| | |
| | | "time" |
| | | ) |
| | | |
| | | |
| | | func Parsesources(sources []map[string]interface{}) (multiInfos []*protomsg.MultiFeaCache) { |
| | | var ok bool |
| | | for _, source := range sources { |
| | |
| | | return total, nil |
| | | } |
| | | |
| | | func SourceAggregationList(buf []byte) (sources []map[string]interface{}, err error) { |
| | | var info interface{} |
| | | json.Unmarshal(buf, &info) |
| | | out, ok := info.(map[string]interface{}) |
| | | if !ok { |
| | | return nil, errors.New("http response interface can not change map[string]interface{}") |
| | | } |
| | | |
| | | middle, ok := out["aggregations"].(map[string]interface{}) |
| | | if !ok { |
| | | return nil, errors.New("first hits change error!") |
| | | } |
| | | |
| | | documentAggregations := middle["group_by_documentnumber"].(map[string]interface{}) |
| | | buckets := documentAggregations["buckets"].([]interface{}) |
| | | if len(buckets) == 0 { |
| | | return nil, nil |
| | | } |
| | | for _, in := range buckets { |
| | | tmpbuf, ok := in.(map[string]interface{}) |
| | | if !ok { |
| | | return nil, errors.New("") |
| | | } |
| | | sources = append(sources, tmpbuf) |
| | | } |
| | | return sources, nil |
| | | } |
| | | |
| | | func EsReq(method string, url string, parama []byte) (buf []byte, err error) { |
| | | //defer elapsed("page")() |
| | | timeout := time.Duration(100 * time.Second) |
| | |
| | | Username string `mapstructure: "username"` |
| | | Userpassword string `mapstructure: "userpassword"` |
| | | } |
| | | |
| | | |
| | | var Account = &account{} |
| | | |