ldc-dam/app/Console/Commands/reindexElasticMedia.php
Vincent BRIDIER 09acec76f7 - Fix bug recherche sur brouillon
- Fix recherche avec ajout recherche via mots-clés
- On cache tout ce qui concerne les etiquettes
- Fix Index ElastichSearch quand on creer un media
- Refonte du process d'ajout de medias
2019-10-31 11:58:14 +01:00

59 lines
1.2 KiB
PHP

<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Models\Media;
class reindexElasticMedia extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'medias:reindex';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Reindex la base médias dans Elasticsearch';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$this->info('Reindexation de la base médias dans Elasticsearch...');
if (Media::indexExists())
Media::deleteIndex();
Media::createIndex();
$medias = Media::all();
$bar = $this->output->createProgressBar(count($medias));
$bar->start();
foreach ($medias as $media) {
// ---- index le media dans Elasticsearch
$media->addToIndex();
$bar->advance();
}
$bar->finish();
$this->line("");
$this->info('Fin du traitement');
}
}