/** * Handle index creation command * * @param Client $client * @param string $index */ public function handle(Client $client, $index, $type) { $config = $this->configurationRepository->get($index); if ($this->isInvalid($config, $type)) { throw new \InvalidArgumentException(); } $client->indices()->putMapping(['index' => $index, 'type' => $type, 'body' => [$type => $config['mappings'][$type]]]); }
/** * Handle index creation command * * @param Client $client * @param string $index */ public function handle($client, $index) { $config = $this->configurationRepository->get($index); if (null === $client || null === $config) { throw new \InvalidArgumentException(); } $client->indices()->putSettings(['index' => $index, 'body' => ['settings' => $this->extractSettings($config)]]); }
/** * Handle index creation command * * @param Client $client * @param string $index */ public function handle(Client $client, $index) { $config = $this->configurationRepository->get($index); if (null === $config) { throw new \InvalidArgumentException(); } $client->indices()->create(['index' => $index, 'body' => $config]); }