reduce complexity of rebuild command
This commit is contained in:
parent
53651328bb
commit
4e6f560376
|
|
@ -18,5 +18,5 @@ return [
|
|||
->get('/blomstra/search/{type}', 'blomstra.search', Api\Controllers\SearchController::class),
|
||||
|
||||
(new Flarum\Console)
|
||||
->command(Commands\RebuildDocumentsCommand::class)
|
||||
->command(Commands\BuildCommand::class)
|
||||
];
|
||||
|
|
|
|||
|
|
@ -11,11 +11,9 @@ use Illuminate\Contracts\Container\Container;
|
|||
use Illuminate\Contracts\Queue\Queue;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
|
||||
class RebuildDocumentsCommand extends Command
|
||||
class BuildCommand extends Command
|
||||
{
|
||||
protected $signature = 'blomstra:search:documents:rebuild
|
||||
{--flush : Flushes ALL the documents inside the index}
|
||||
{--mapping : Create property mappings: booleans, dates and fulltext searches}
|
||||
protected $signature = 'blomstra:search:index
|
||||
{--max-id= : Limits for each object the number of items to seed}';
|
||||
protected $description = 'Rebuilds the complete search server with its documents.';
|
||||
|
||||
|
|
@ -49,12 +47,12 @@ class RebuildDocumentsCommand extends Command
|
|||
];
|
||||
|
||||
// Flush the index.
|
||||
if ($this->option('flush')) {
|
||||
$client->indices()->delete([
|
||||
'index' => $index,
|
||||
'ignore_unavailable' => true
|
||||
]);
|
||||
|
||||
// Create a new index.
|
||||
$client->indices()->create([
|
||||
'index' => $index,
|
||||
'body' => [
|
||||
|
|
@ -69,14 +67,11 @@ class RebuildDocumentsCommand extends Command
|
|||
]
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
if ($this->option('mapping')) {
|
||||
$client->indices()->putMapping([
|
||||
'index' => $index,
|
||||
'body' => $properties
|
||||
]);
|
||||
}
|
||||
|
||||
/** @var Seeder $seeder */
|
||||
foreach ($seeders as $seeder) {
|
||||
Loading…
Reference in New Issue