Exemple #1
0
 /**
  * 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.");
     }
 }
Exemple #2
0
 /**
  * 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);
     }
 }
Exemple #3
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $indexName = $this->option('index') ?: '_all';
     $wait = $this->option('wait') ? true : false;
     $dump = $this->option('dump') ? true : false;
     $this->indexManager->closeIndex($indexName);
     $results = $this->indexManager->upgrade($indexName, $wait);
     $this->indexManager->openIndex($indexName);
     if ($dump) {
         (new Dumper())->dump($results);
     } else {
         $this->printResults($results);
     }
 }
Exemple #4
0
 /**
  * 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']);
     }
 }
Exemple #5
0
 /**
  * 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"));
     }
 }
Exemple #6
0
 /**
  * Create a new index.
  *
  * @param  string $indexName
  * @param  array $settings
  * @return void
  */
 protected function createIndex($indexName, $settings)
 {
     $this->indexManager->createIndex($indexName, $settings);
 }
Exemple #7
0
 /**
  * Run the suggestion request.
  *
  * @param  string|null $index
  * @return \Elodex\SuggestResult
  */
 public function get($index = null)
 {
     return $this->indexManager->suggest($this, $index);
 }
Exemple #8
0
 /**
  * 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.");
 }