]> BookStack Code Mirror - bookstack/blobdiff - app/Console/Commands/RegenerateSearch.php
Updated minimum php version from 7.3 to 7.4
[bookstack] / app / Console / Commands / RegenerateSearch.php
index 3dc3ec0af0e98b33bd3f1d741540dd13e1d319c5..20e3fc7983f8bd7ff472758d20f3693841864ec5 100644 (file)
@@ -2,9 +2,10 @@
 
 namespace BookStack\Console\Commands;
 
+use BookStack\Entities\Models\Entity;
 use BookStack\Entities\Tools\SearchIndex;
-use DB;
 use Illuminate\Console\Command;
+use Illuminate\Support\Facades\DB;
 
 class RegenerateSearch extends Command
 {
@@ -22,6 +23,9 @@ class RegenerateSearch extends Command
      */
     protected $description = 'Re-index all content for searching';
 
+    /**
+     * @var SearchIndex
+     */
     protected $searchIndex;
 
     /**
@@ -45,8 +49,13 @@ class RegenerateSearch extends Command
             DB::setDefaultConnection($this->option('database'));
         }
 
-        $this->searchIndex->indexAllEntities();
+        $this->searchIndex->indexAllEntities(function (Entity $model, int $processed, int $total): void {
+            $this->info('Indexed ' . class_basename($model) . ' entries (' . $processed . '/' . $total . ')');
+        });
+
         DB::setDefaultConnection($connection);
-        $this->comment('Search index regenerated');
+        $this->line('Search index regenerated!');
+
+        return static::SUCCESS;
     }
 }