private function getMetrics($rawValue)
    {
        $metrics = [];

        foreach ($rawValue as $metricName => $value) {
            if (!is_array($value) || !isset($value['buckets'])) {
                $metricName = $metricName == 'doc_count' ? 'count' : $metricName;
                if (is_array($value) && isset($value['value_as_string'])) {
                    $value = $value['value_as_string'];
                } elseif (is_array($value) && isset($value['value'])) {
                    $value = $value['value'];
                }
                $metrics[$metricName] = $value;
            }
        }

        return $metrics;
    }