public function createManager($managerName, $connection, $analysis, $managerConfig)
    {
        $mappings = $this->metadataCollector->getClientMapping($managerConfig['mappings']);

        $client = ClientBuilder::create();
        $client->setHosts($connection['hosts']);
        $client->setTracer($this->tracer);

        if ($this->logger && $managerConfig['logger']['enabled']) {
            $client->setLogger($this->logger);
        }

        $indexSettings = [
            'index' => $connection['index_name'],
            'body' => array_filter(
                [
                    'settings' => array_merge(
                        $connection['settings'],
                        [
                            'analysis' =>
                                $this->metadataCollector->getClientAnalysis($managerConfig['mappings'], $analysis),
                        ]
                    ),
                    'mappings' => $mappings,
                ]
            ),
        ];

        $this->eventDispatcher &&
            $this->eventDispatcher->dispatch(
                Events::PRE_MANAGER_CREATE,
                new PreCreateManagerEvent($client, $indexSettings)
            );

        $manager = new Manager(
            $managerName,
            $managerConfig,
            $client->build(),
            $indexSettings,
            $this->metadataCollector,
            $this->converter
        );

        if (isset($this->stopwatch)) {
            $manager->setStopwatch($this->stopwatch);
        }

        $manager->setCommitMode($managerConfig['commit_mode']);
        $manager->setEventDispatcher($this->eventDispatcher);
        $manager->setCommitMode($managerConfig['commit_mode']);
        $manager->setBulkCommitSize($managerConfig['bulk_size']);

        $this->eventDispatcher &&
            $this->eventDispatcher->dispatch(Events::POST_MANAGER_CREATE, new PostCreateManagerEvent($manager));

        return $manager;
    }