package public import ( "app.yhyue.com/moapp/jybase/encrypt" elastic "app.yhyue.com/moapp/jybase/es" esV7 "github.com/olivere/elastic/v7" ) // GetAggs 聚合查询 func GetAggs(index, itype, query string) (aggs esV7.Aggregations, count int64, res []map[string]interface{}) { v1, c, v2 := elastic.GetAggs(index, itype, query) return v1, c, v2 } // GetAggs 聚合查询 //func GetAggs_old(index, itype, query string) (aggs elastic2.Aggregations, count int64, hist []*elastic2.SearchHit) { // defer util.Catch() // client := elastic.GetEsConn() // defer func() { // go elastic.DestoryEsConn(client) // }() // if client != nil { // defer func() { // if r := recover(); r != nil { // log.Println("[SEARCH-ERR]", r) // for skip := 1; ; skip++ { // _, file, line, ok := runtime.Caller(skip) // if !ok { // break // } // go log.Printf("[SEARCH-INFO]%v,%v\n", file, line) // } // } // }() // searchResult, err := client.Search().Index(index).Type(itype).Source(query).Do() // if err != nil { // log.Println("[SEARCH-ERR]从ES查询出错", err.Error()) // } // count = searchResult.Hits.TotalHits // hist = searchResult.Hits.Hits // aggs = searchResult.Aggregations // } // return //} // EncodeId 加密 func EncodeId(sid string) string { if sid == "" { return "" } return encrypt.EncodeArticleId2ByCheck(sid) } // DecodeId 解密 func DecodeId(eid string) string { if eid == "" { return "" } return encrypt.DecodeArticleId2ByCheck(eid)[0] }