elasticsearch: more robust field order (#65102)

This commit is contained in:
Gábor Farkas
2023-03-21 13:44:10 +01:00
committed by GitHub
parent 23e3ac0ac9
commit 335bcd1e4e
2 changed files with 13 additions and 2 deletions

View File

@@ -693,7 +693,7 @@ func processAggregationDocs(esAgg *simplejson.Json, aggDef *BucketAgg, target *Q
}
case percentilesType:
percentiles := bucket.GetPath(metric.ID, "values")
for percentileName := range percentiles.MustMap() {
for _, percentileName := range getSortedKeys(percentiles.MustMap()) {
percentileValue := percentiles.Get(percentileName).MustFloat64()
addMetricValue(values, fmt.Sprintf("p%v %v", percentileName, metric.Field), &percentileValue)
}
@@ -1129,3 +1129,14 @@ func createFieldsFromPropKeys(frames data.Frames, propKeys []string) []*data.Fie
}
return fields
}
func getSortedKeys(data map[string]interface{}) []string {
keys := make([]string, 0, len(data))
for k := range data {
keys = append(keys, k)
}
sort.Strings(keys)
return keys
}

View File

@@ -1030,7 +1030,7 @@ func TestPercentilesWithoutDateHistogram(t *testing.T) {
"3": {
"buckets": [
{
"1": { "values": { "75": 3.3, "90": 5.5 } },
"1": { "values": { "90": 5.5, "75": 3.3 } },
"doc_count": 10,
"key": "id1"
},