/** * Factory function to create a manager instance. * * @param string $managerName Manager name. * @param array $connection Connection configuration. * @param array $analysis Analyzers, filters and tokenizers config. * @param array $managerConfig Manager configuration. * * @return Manager */ public function createManager($managerName, $connection, $analysis, $managerConfig) { foreach (array_keys($analysis) as $analyzerType) { foreach ($connection['analysis'][$analyzerType] as $name) { $connection['settings']['analysis'][$analyzerType][$name] = $analysis[$analyzerType][$name]; } } unset($connection['analysis']); $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' => $connection['settings'], 'mappings' => $mappings])]; $manager = new Manager($managerName, $managerConfig, $client->build(), $indexSettings, $this->metadataCollector, $this->converter); $manager->setCommitMode($managerConfig['commit_mode']); $manager->setBulkCommitSize($managerConfig['bulk_size']); return $manager; }