mirror of
https://github.com/grafana/grafana.git
synced 2024-11-24 09:50:29 -06:00
Elasticsearch: Fix adding correct min_doc_count to all aggregation types in backend implementation (#59713)
* Elasticsearch: Fix adding correct min_doc_count to all aggregation types in backend implementation * Update snapshot tests * Fix linting
This commit is contained in:
parent
dce7f50d59
commit
13acddd605
@ -29,6 +29,7 @@
|
||||
},
|
||||
"terms": {
|
||||
"field": "label",
|
||||
"min_doc_count": 1,
|
||||
"order": {
|
||||
"_key": "desc"
|
||||
},
|
||||
|
@ -17,6 +17,7 @@
|
||||
},
|
||||
"terms": {
|
||||
"field": "label",
|
||||
"min_doc_count": 1,
|
||||
"order": {
|
||||
"_key": "desc"
|
||||
},
|
||||
|
@ -227,11 +227,7 @@ func (metricAggregation MetricAgg) generateSettingsForDSL() map[string]interface
|
||||
}
|
||||
|
||||
func (bucketAgg BucketAgg) generateSettingsForDSL() map[string]interface{} {
|
||||
// TODO: This might also need to be applied to other bucket aggregations and other fields.
|
||||
switch bucketAgg.Type {
|
||||
case "date_histogram":
|
||||
setIntPath(bucketAgg.Settings, "min_doc_count")
|
||||
}
|
||||
setIntPath(bucketAgg.Settings, "min_doc_count")
|
||||
|
||||
return bucketAgg.Settings.MustMap()
|
||||
}
|
||||
|
@ -310,9 +310,9 @@ func TestExecuteTimeSeriesQuery(t *testing.T) {
|
||||
sr := c.multisearchRequests[0].Requests[0]
|
||||
firstLevel := sr.Aggs[0]
|
||||
require.Equal(t, firstLevel.Key, "2")
|
||||
// FIXME: This is a bug in the current implementation. The min_doc_count is not set.
|
||||
// termsAgg := firstLevel.Aggregation.Aggregation.(*es.TermsAggregation)
|
||||
// require.Equal(t, termsAgg.MinDocCount, "1")
|
||||
termsAgg := firstLevel.Aggregation.Aggregation.(*es.TermsAggregation)
|
||||
expectedMinDocCount := 1
|
||||
require.Equal(t, termsAgg.MinDocCount, &expectedMinDocCount)
|
||||
})
|
||||
|
||||
t.Run("With metric percentiles", func(t *testing.T) {
|
||||
|
Loading…
Reference in New Issue
Block a user