sunty
2024-03-25 ebfa610f8c66fd2827a2eec619bfb3e0e22c332f
EsClient.go
@@ -15,7 +15,6 @@
   "time"
)
func Parsesources(sources []map[string]interface{}) (multiInfos []*protomsg.MultiFeaCache) {
   var ok bool
   for _, source := range sources {
@@ -1045,6 +1044,34 @@
   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)
@@ -1094,7 +1121,6 @@
   Username string `mapstructure: "username"`
   Userpassword string `mapstructure: "userpassword"`
}
var Account = &account{}