update solr index
This commit is contained in:
parent
7c6654398d
commit
535a9363cc
18 changed files with 773 additions and 90 deletions
68
app/Listeners/DatasetUpdated.php
Normal file
68
app/Listeners/DatasetUpdated.php
Normal file
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
|
||||
namespace App\Listeners;
|
||||
|
||||
// use Illuminate\Queue\InteractsWithQueue;
|
||||
// use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use App\Events\Dataset\DatasetUpdated as DatasetUpdatedEvent;
|
||||
use App\Models\Dataset;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Library\Search\SolariumAdapter;
|
||||
|
||||
class DatasetUpdated
|
||||
{
|
||||
/**
|
||||
* Create the event listener.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
* @param DatasetUpdatedEvent $event
|
||||
* @return void
|
||||
*/
|
||||
public function handle(DatasetUpdatedEvent $event)
|
||||
{
|
||||
$dataset = $event->dataset;
|
||||
// only index Opus_Document instances
|
||||
if (false === ($dataset instanceof Dataset)) {
|
||||
return;
|
||||
}
|
||||
if ($dataset->server_state !== 'published') {
|
||||
// if ($dataset->getServerState() !== 'temporary') {
|
||||
// $this->removeDocumentFromIndexById($model->getId());
|
||||
// }
|
||||
return;
|
||||
}
|
||||
|
||||
$this->addDatasetToIndex($dataset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to add dataset to index.
|
||||
*
|
||||
* @param Opus_Document $document
|
||||
* @return void
|
||||
*/
|
||||
private function addDatasetToIndex(Dataset $dataset)
|
||||
{
|
||||
$datasetId = $dataset->id;
|
||||
Log::debug(__METHOD__ . ': ' . 'Adding index job for dataset ' . $datasetId . '.');
|
||||
|
||||
try {
|
||||
// Opus_Search_Service::selectIndexingService('onDocumentChange')
|
||||
$service = new SolariumAdapter("solr", config('solarium'));
|
||||
$service->addDatasetsToIndex($dataset);
|
||||
} catch (Opus_Search_Exception $e) {
|
||||
Log::debug(__METHOD__ . ': ' . 'Indexing document ' . $documentId . ' failed: ' . $e->getMessage());
|
||||
} catch (InvalidArgumentException $e) {
|
||||
Log::warning(__METHOD__ . ': ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
editor.link_modal.header
Reference in a new issue