/** * Execute the console command. * * @return mixed */ public function handle() { $indexName = $this->option('index') ?: $this->indexManager->getDefaultIndex(); $force = $this->option('force') ? true : false; if ($force || $this->confirm("Do you really want to delete the index '{$indexName}' ? [y|N]")) { $this->indexManager->deleteIndex($indexName); $this->info("Index '{$indexName}' successfully deleted."); } }
/** * Execute the console command. * * @return mixed */ public function handle() { $indexName = $this->option('index') ?: $this->indexManager->getDefaultIndex(); $dump = $this->option('dump') ? true : false; $stats = $this->indexManager->stats($indexName); if ($dump) { (new Dumper())->dump($stats); } else { $this->printStats($stats); } }
/** * Execute the console command. * * @return mixed */ public function handle() { $analyzer = $this->argument('analyzer'); $text = $this->argument('text'); $indexName = $this->option('index') ?: $this->indexManager->getDefaultIndex(); $dump = $this->option('dump') ? true : false; $filters = $this->option('filter') ? explode(',', $this->option('filter')) : []; $tokenizer = $this->option('tokenizer'); $results = $this->indexManager->analyze($analyzer, $text, $filters, $tokenizer, $indexName); if ($dump) { (new Dumper())->dump($results); } else { $this->printTokens($results['tokens']); } }
/** * Execute the console command. * * @return mixed * @throws \Symfony\Component\Console\Exception\InvalidArgumentException */ public function handle() { $class = $this->option('class'); $dump = $this->option('dump') ? true : false; $indexName = $this->option('index') ?: $this->indexManager->getDefaultIndex(); $indexTypeName = null; if (!empty($class)) { if (!class_exists($class)) { throw new InvalidArgumentException("Specified class '{$class}' is not valid or does not exist."); } $model = new $class(); if (!$model instanceof IndexedModel) { throw new InvalidArgumentException("Class '{$class}' is not an indexed model class."); } $indexTypeName = $model->getIndexTypeName(); } $mappings = $this->indexManager->getMappings($indexName, $indexTypeName); if (empty($mappings)) { $this->warn('No mappings found.'); return 1; } if ($dump) { (new Dumper())->dump($mappings); return 0; } if (empty($class)) { foreach ($mappings as $data) { foreach ($data['mappings'] as $t => $m) { $this->info("Index property mappings for type '{$t}':"); $this->printMappings($m['properties']); $this->line(''); } } } else { $this->info("Index property mappings for model class '{$class}':"); $this->printMappings(Arr::get($mappings, "{$indexName}.mappings.{$indexTypeName}.properties")); } }
/** * Execute the console command. * * @return mixed */ public function handle() { $indexName = $this->option('index') ?: $this->indexManager->getDefaultIndex(); $reset = $this->option('reset') ?: false; if ($this->indexManager->indicesExist([$indexName])) { if ($reset) { $this->resetIndex($indexName); } else { $this->error("Index '{$indexName}' already exists, exiting. Use --reset to force the creation of a new index."); return 1; } } $settings = []; $shards = $this->option('shards'); if (!is_null($shards)) { $settings['number_of_shards'] = $shards; } $replicas = $this->option('replicas'); if (!is_null($replicas)) { $settings['number_of_replicas'] = $replicas; } $this->createIndex($indexName, $settings); $this->info("Index '{$indexName}' successfully created."); }
/** * Execute the console command. * * @return mixed */ public function handle() { $indexName = $this->option('index') ?: $this->indexManager->getDefaultIndex(); $this->indexManager->openIndex($indexName); $this->info("Index '{$indexName}' successfully opened."); }