public function buildBoostedFields($fields)
    {
        // Assume strings are pre-formatted.
        if (is_string($fields)) {
            return $fields;
        }

        $processed = array();
        foreach ($fields as $fieldName => $boost) {
            if (!is_array($boost)) {
                $processed[] = $fieldName . '^' . $boost;
            } else {
                $field = $fieldName . '~' . $boost[0];
                if (isset($boost[1])) {
                    $field .= '^' . $boost[1];
                }
                $processed[] = $field;
            }
        }
        return join(',', $processed);
    }