1161
}
1162
1164
>
1165
>
groupByTypes := make([]enumspb.IndexedValueType, len(groupByFields))
1166
>
for i, saName := range groupByFields {
1167
>
tp, err := combinedTypeMap.GetType(saName)
1168
>
if err != nil {
1169
return nil, err
1170
}
1172
}
1173
1175
>
numberVal, isNumber := val.(json.Number)
1176
>
if !isNumber {
1177
return 0, fmt.Errorf("%w: expected json.Number, got %T", errUnexpectedJSONFieldType, val)
1178
}
1180
}
1181
1183
>
parseInternal = func(aggs map[string]any, bucketValues []*commonpb.Payload) error {
1184
>
if len(bucketValues) == len(groupByFields) {
1185
>
cnt, err := parseJsonNumber(aggs["doc_count"])
1186
>
if err != nil {
1187
return fmt.Errorf("unable to parse 'doc_count' field: %w", err)
1188
}
1190
>
copy(groupValues, bucketValues)
1191
>
response.Groups = append(
1192
>
response.Groups,
1193
>
store.InternalAggregationGroup{
1194
>
GroupValues: groupValues,
1195
>
Count: cnt,
1196
>
},
1197
>
)
1198
>
response.Count += cnt
1199
>
return nil
1200
}
1201
1203
>
fieldName := groupByFields[index]
1204
>
buckets := aggs[fieldName].(map[string]any)["buckets"].([]any)
1205
>
for i := range buckets {
1206
>
bucket := buckets[i].(map[string]any)
1207
>
value, err := finishParseJSONValue(bucket["key"], groupByTypes[index])
1208
>
if err != nil {
1209
return fmt.Errorf("unable to parse value %v: %w", bucket["key"], err)
1210
}
1212
>
if err != nil {
1213
return fmt.Errorf("unable to encode value %v: %w", value, err)
1214
}
1216
>
if err != nil {
1217
return err
1218
}
1219
}
1221
}
1222
1224
>
dec := json.NewDecoder(bytes.NewReader(searchResult.Aggregations[groupByFields[0]]))
1225
>
dec.UseNumber()
1226
>
if err := dec.Decode(&bucketsJson); err != nil {
1227
return nil, serviceerror.NewInternalf("unable to unmarshal json response: %v", err)
1228
}
1229
>
if err := parseInternal(map[string]any{groupByFields[0]: bucketsJson}, nil); err != nil {
visibility_store.go
1230
return nil, err
1231
}
1233
}
1234