/** * Handle index creation command * * @param Client $client * @param string $index * @param string $type * @param string $alias */ public function handle(Client $client, $index, $type, $alias) { $mapping = $this->configurations->getMapping($alias, $type); if (!$mapping) { throw new \InvalidArgumentException(); } $client->getIndex($index)->getType($type)->setMapping($mapping); }
public function testGetMapping() { $configs = ['my_index' => ['mappings' => ['my_type' => ['properties' => ['property' => 'value']], 'my_type_2' => ['config']]]]; $testedInstance = new IndexConfigurationRepository($configs); $mapping = $testedInstance->getMapping('my_index', 'my_type'); $this->assertEquals(['property' => 'value'], $mapping); $mapping = $testedInstance->getMapping('my_index', 'my_type_2'); $this->assertEquals([], $mapping); $mapping = $testedInstance->getMapping('my_index', 'my_type_fake'); $this->assertEquals(null, $mapping); }