feat: add date_histogram agg.

This commit is contained in:
Jacky Wu
2022-01-21 14:09:06 +08:00
parent 49a92fc25e
commit c2693c6401
2 changed files with 165 additions and 1 deletions
+24 -1
View File
@@ -62,7 +62,14 @@ func TestAggregations(t *testing.T) {
"a complex, multi-aggregation, nested",
Aggregate(
NestedAgg("categories", "categories").
Aggs(TermsAgg("type", "outdoors")),
Aggs(
TermsAgg("type", "outdoors").Aggs(
DateHistogramAgg("time", "timestamp").
Fixedinterval("3m").MinDocCount(0).Aggs(
Sum("sumPeople", "people"),
),
),
),
FilterAgg("filtered",
Term("type", "t-shirt")),
),
@@ -77,6 +84,22 @@ func TestAggregations(t *testing.T) {
"terms": map[string]interface{}{
"field": "outdoors",
},
"aggs": map[string]interface{}{
"time": map[string]interface{}{
"date_histogram": map[string]interface{}{
"field": "timestamp",
"fixed_interval": "3m",
"min_doc_count": 0,
},
"aggs": map[string]interface{}{
"sumPeople": map[string]interface{}{
"sum": map[string]interface{}{
"field": "people",
},
},
},
},
},
},
},
},