|
@@ -6,6 +6,8 @@ import (
|
|
|
"log"
|
|
|
"runtime"
|
|
|
"strings"
|
|
|
+
|
|
|
+ esV7 "github.com/olivere/elastic/v7"
|
|
|
)
|
|
|
|
|
|
const (
|
|
@@ -33,26 +35,6 @@ const (
|
|
|
HL_IK = `"highlight": {"pre_tags": ["` + IK_pre_tags + `"],"post_tags": ["` + IK_post_tags + `"],"fields": {%s}}`
|
|
|
)
|
|
|
|
|
|
-type Aggregations map[string]json.RawMessage
|
|
|
-type AggregationSingleBucket struct {
|
|
|
- Aggregations
|
|
|
-
|
|
|
- DocCount int64 // `json:"doc_count"`
|
|
|
-}
|
|
|
-
|
|
|
-func (a Aggregations) Children(name string) (*AggregationSingleBucket, bool) {
|
|
|
- if raw, found := a[name]; found {
|
|
|
- agg := new(AggregationSingleBucket)
|
|
|
- if raw == nil {
|
|
|
- return agg, true
|
|
|
- }
|
|
|
- if err := json.Unmarshal(raw, agg); err == nil {
|
|
|
- return agg, true
|
|
|
- }
|
|
|
- }
|
|
|
- return nil, false
|
|
|
-}
|
|
|
-
|
|
|
type Es interface {
|
|
|
Init()
|
|
|
Save(index, itype string, obj interface{}) bool
|
|
@@ -85,7 +67,7 @@ type Es interface {
|
|
|
GetAllByIk(index, itype, qstr, findfields, order, fields string, start, limit, count int, highlight bool) *[]map[string]interface{}
|
|
|
GetResForJYView(index, itype string, keys []KeyConfig, allquery, findfields, SortQuery, fields string, start, limit int) *[]map[string]interface{}
|
|
|
GetWithCount(index, itype, query string) (int64, *[]map[string]interface{})
|
|
|
- GetAggs(index, itype, query string) (aggs Aggregations, count int64, res []map[string]interface{})
|
|
|
+ GetAggs(index, itype, query string) (aggs esV7.Aggregations, count int64, res []map[string]interface{})
|
|
|
}
|
|
|
|
|
|
var (
|
|
@@ -262,6 +244,6 @@ func GetResForJYView(index, itype string, keys []KeyConfig, allquery, findfields
|
|
|
func GetWithCount(index, itype, query string) (int64, *[]map[string]interface{}) {
|
|
|
return VarEs.GetWithCount(index, itype, query)
|
|
|
}
|
|
|
-func GetAggs(index, itype, query string) (aggs Aggregations, count int64, res []map[string]interface{}) {
|
|
|
+func GetAggs(index, itype, query string) (aggs esV7.Aggregations, count int64, res []map[string]interface{}) {
|
|
|
return VarEs.GetAggs(index, itype, query)
|
|
|
}
|