protected function adjustStringTypeMapping(array &$mapping): void
    {
        $adjustStringTypeMapping = function (&$item) {
            if (isset($item['type']) && $item['type'] === 'string') {
                if (isset($item['index'])) {
                    if ($item['index'] === 'not_analyzed') {
                        $item['type'] = 'keyword';
                        $item['index'] = true;
                        unset($item['analyzer']);
                    } elseif ($item['index'] === 'no') {
                        $item['type'] = 'text';
                        $item['index'] = false;
                    } elseif ($item['index'] === 'analyzed') {
                        $item['type'] = 'text';
                        $item['index'] = true;
                    }
                } else {
                    $item['type'] = 'keyword';
                    $item['index'] = true;
                }
            }
        };

        $adjustStringTypeMapping($mapping);

        foreach ($mapping as &$item) {
            if (is_array($item)) {
                $adjustStringTypeMapping($mapping);
                $this->adjustStringTypeMapping($item);
            }
        }
    }