3 namespace BookStack\Console\Commands;
5 use BookStack\Entities\Tools\SearchIndex;
7 use Illuminate\Console\Command;
9 class RegenerateSearch extends Command
12 * The name and signature of the console command.
16 protected $signature = 'bookstack:regenerate-search {--database= : The database connection to use.}';
19 * The console command description.
23 protected $description = 'Re-index all content for searching';
25 protected $searchIndex;
28 * Create a new command instance.
30 public function __construct(SearchIndex $searchIndex)
32 parent::__construct();
33 $this->searchIndex = $searchIndex;
37 * Execute the console command.
41 public function handle()
43 $connection = DB::getDefaultConnection();
44 if ($this->option('database') !== null) {
45 DB::setDefaultConnection($this->option('database'));
48 $this->searchIndex->indexAllEntities();
49 DB::setDefaultConnection($connection);
50 $this->comment('Search index regenerated');