From 5b358a37ddfe575d4f7e9e29c4d2c36bc592d0cc Mon Sep 17 00:00:00 2001
From: sunty <1172534965@qq.com>
Date: 星期日, 29 九月 2019 11:40:54 +0800
Subject: [PATCH] fix EsApi
---
EsApi.go | 19 ++++++++++---------
1 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/EsApi.go b/EsApi.go
index f810f72..f3af819 100644
--- a/EsApi.go
+++ b/EsApi.go
@@ -622,9 +622,9 @@
return total,nil
}
//瀹炴椂鎶ヨ浠诲姟姣旂巼
-func RealTimeAlarmTaskRate(serverIp string, serverPort string,indexName string) (sources map[string]int,err error){
+func RealTimeAlarmTaskRate(serverIp string, serverPort string) (sources []map[string]interface{},err error){
url := "http://" + serverIp + ":" + serverPort +
- "/"+indexName+"/_search"
+ "/videopersons,personaction/_search"
DSLJson := `{
"size":0,
"query":{
@@ -647,7 +647,7 @@
}
}`
buf, err := EsReq("POST",url,[]byte(DSLJson))
- if err != nil {
+ if err != nil {
return nil, err
}
var info interface{}
@@ -664,8 +664,9 @@
if !ok {
return nil, errors.New("first hits change error!")
}
- var source = make(map[string]int,0)
+
for _, in := range sdkName_status["buckets"].([]interface{}){
+ var source = make(map[string]interface{},0)
tmpbuf, ok := in.(map[string]interface{})
if !ok {
fmt.Println("change to source error!")
@@ -673,10 +674,10 @@
}
sdkName := tmpbuf["key"].(string)
count := int(tmpbuf["doc_count"].(float64))
- source[sdkName] = count
- //fmt.Println("in",in)
- //sources[in["key"].(string)] = int(in["doc_count"].(float64))
+ source["name"] = sdkName
+ source["value"] = count
+ sources = append(sources, source)
}
- //fmt.Println("sources",source)
- return source,nil
+ //fmt.Println("tmpSource",sources)
+ return sources,nil
}
--
Gitblit v1.8.0