@@ 15-56 (lines=42) @@ | ||
12 | * |
|
13 | * @author gbprod <[email protected]> |
|
14 | */ |
|
15 | class AddAliasCommand extends ElasticaAwareCommand |
|
16 | { |
|
17 | /** |
|
18 | * {@inheritdoc} |
|
19 | */ |
|
20 | protected function configure() |
|
21 | { |
|
22 | $this |
|
23 | ->setName('elasticsearch:alias:add') |
|
24 | ->setDescription('Add alias to an index') |
|
25 | ->addArgument('index', InputArgument::REQUIRED, 'Which index ?') |
|
26 | ->addArgument('alias', InputArgument::REQUIRED, 'Alias name') |
|
27 | ->addOption('replace', null, InputOption::VALUE_NONE, 'If set, an existing alias will be replaced') |
|
28 | ->addOption('client', null, InputOption::VALUE_REQUIRED, 'Client to use (if not default)', null) |
|
29 | ; |
|
30 | } |
|
31 | ||
32 | /** |
|
33 | * {@inheritdoc} |
|
34 | */ |
|
35 | protected function execute(InputInterface $input, OutputInterface $output) |
|
36 | { |
|
37 | $client = $this->getClient($input->getOption('client')); |
|
38 | $index = $input->getArgument('index'); |
|
39 | $alias = $input->getArgument('alias'); |
|
40 | $replace = $input->getOption('replace'); |
|
41 | ||
42 | $output->writeln(sprintf( |
|
43 | '<info>Add alias <comment>%s</comment> for index <comment>%s</comment></info>', |
|
44 | $alias, |
|
45 | $index |
|
46 | )); |
|
47 | ||
48 | $this |
|
49 | ->getContainer() |
|
50 | ->get('gbprod.elastica_extra.add_alias_handler') |
|
51 | ->handle($client, $index, $alias, $replace); |
|
52 | ; |
|
53 | ||
54 | $output->writeln('done'); |
|
55 | } |
|
56 | } |
|
57 |
@@ 15-51 (lines=37) @@ | ||
12 | * |
|
13 | * @author gbprod <[email protected]> |
|
14 | */ |
|
15 | class PutIndexMappingsCommand extends ElasticaAwareCommand |
|
16 | { |
|
17 | protected function configure() |
|
18 | { |
|
19 | $this |
|
20 | ->setName('elasticsearch:index:put_mappings') |
|
21 | ->setDescription('Put index mappings from configuration') |
|
22 | ->addArgument('index', InputArgument::REQUIRED, 'Which index ?') |
|
23 | ->addArgument('type', InputArgument::REQUIRED, 'Which type ?') |
|
24 | ->addOption('client', null, InputOption::VALUE_REQUIRED, 'Client to use (if not default)', null) |
|
25 | ; |
|
26 | } |
|
27 | ||
28 | protected function execute(InputInterface $input, OutputInterface $output) |
|
29 | { |
|
30 | $client = $this->getClient($input->getOption('client')); |
|
31 | $index = $input->getArgument('index'); |
|
32 | $type = $input->getArgument('type'); |
|
33 | ||
34 | $output->writeln(sprintf( |
|
35 | '<info>Put type <comment>%s</comment> mappings for index <comment>%s</comment> '. |
|
36 | 'client <comment>%s</comment>...</info>', |
|
37 | $type, |
|
38 | $index, |
|
39 | $input->getOption('client') |
|
40 | )); |
|
41 | ||
42 | $handler = $this |
|
43 | ->getContainer() |
|
44 | ->get('gbprod.elastica_extra.put_index_mappings_handler') |
|
45 | ; |
|
46 | ||
47 | $handler->handle($client, $index, $type); |
|
48 | ||
49 | $output->writeln('done'); |
|
50 | } |
|
51 | } |
|
52 |