2023-02-02 23:41:56 +08:00
|
|
|
package opensearch_query
|
|
|
|
|
|
|
|
|
|
import "fmt"
|
|
|
|
|
|
2024-12-06 00:35:28 +08:00
|
|
|
type metricAggregationRequest map[string]*aggregationFunction
|
2023-02-02 23:41:56 +08:00
|
|
|
|
2024-12-06 00:35:28 +08:00
|
|
|
func (m metricAggregationRequest) addAggregation(name, aggType, field string) error {
|
2024-07-10 18:51:25 +08:00
|
|
|
if t := getAggregationFunctionType(aggType); t != "metric" {
|
2023-02-02 23:41:56 +08:00
|
|
|
return fmt.Errorf("aggregation function %q not supported", aggType)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m[name] = &aggregationFunction{
|
|
|
|
|
aggType: aggType,
|
|
|
|
|
field: field,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|