-
Notifications
You must be signed in to change notification settings - Fork 345
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[9.x] Support Meilisearch index settings (#669)
* Update comment for flush command * Sync index settings for Meilisearch * wip * wip * Update IndexCommand.php * wip * wip * Update FlushCommand.php * Update FlushCommand.php * formatting Co-authored-by: Taylor Otwell <[email protected]>
- Loading branch information
1 parent
5926848
commit 649d5bb
Showing
6 changed files
with
88 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
namespace Laravel\Scout\Console; | ||
|
||
use Exception; | ||
use Illuminate\Console\Command; | ||
use Laravel\Scout\EngineManager; | ||
|
||
class SyncIndexSettingsCommand extends Command | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'scout:sync-index-settings'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Sync your configured index settings with your search engine (MeiliSearch)'; | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @param \Laravel\Scout\EngineManager $manager | ||
* @return void | ||
*/ | ||
public function handle(EngineManager $manager) | ||
{ | ||
$engine = $manager->engine(); | ||
|
||
$driver = config('scout.driver'); | ||
|
||
if (! method_exists($engine, 'updateIndexSettings')) { | ||
return $this->error('The "'.$driver.'" engine does not support updating index settings.'); | ||
} | ||
|
||
try { | ||
$indexes = (array) config('scout.'.$driver.'.index-settings', []); | ||
|
||
if (count($indexes)) { | ||
foreach ($indexes as $name => $settings) { | ||
$engine->updateIndexSettings($name, $settings); | ||
|
||
$this->info('Settings for the ["'.$name.'"] index synced successfully.'); | ||
} | ||
} else { | ||
$this->info('No index settings found for the "'.$driver.'" engine.'); | ||
} | ||
} catch (Exception $exception) { | ||
$this->error($exception->getMessage()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters