util.go 485 B

1234567891011121314151617181920
  1. package elasticsearch
  2. import (
  3. elastic "app.yhyue.com/moapp/jybase/es"
  4. esV7 "github.com/olivere/elastic/v7"
  5. )
  6. // GetAggs 聚合查询
  7. func GetAggs(index, itype, query string) esV7.Aggregations {
  8. v1, _, _ := elastic.GetAggs(index, itype, query)
  9. return v1
  10. }
  11. func GetAggsWithCount(index, itype, query string) (esV7.Aggregations, int64) {
  12. if len(query) > 0 {
  13. query = `{"track_total_hits": true,` + query[1:]
  14. }
  15. v1, v2, _ := elastic.GetAggs(index, itype, query)
  16. return v1, v2
  17. }