update solr index
This commit is contained in:
parent
7c6654398d
commit
535a9363cc
18 changed files with 773 additions and 90 deletions
34
app/Library/Search/SolariumDocument.php
Normal file
34
app/Library/Search/SolariumDocument.php
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace App\Library\Search;
|
||||
|
||||
use App\Models\Dataset;
|
||||
use Solarium\QueryType\Update\Query\Document\Document;
|
||||
|
||||
class SolariumDocument extends SolrDocumentXslt
|
||||
{
|
||||
public function __construct($options)
|
||||
{
|
||||
parent::__construct($options);
|
||||
}
|
||||
|
||||
public function toSolrUpdateDocument(Dataset $rdrDataset, Document $solrDoc)
|
||||
{
|
||||
if (!($solrDoc instanceof Document)) {
|
||||
throw new \Exception('provided Solr document must be instance of Solarium Update Document');
|
||||
}
|
||||
|
||||
// convert Opus document to Solr XML document for supporting custom transformations
|
||||
$solrDomDoc = parent::toSolrDocument($rdrDataset, new \DomDocument());
|
||||
|
||||
// read back fields from generated Solr XML document
|
||||
$solrXmlDoc = simplexml_import_dom($solrDomDoc)->doc[0];
|
||||
|
||||
$solrDoc->clear();
|
||||
foreach ($solrXmlDoc->field as $field) {
|
||||
$solrDoc->addField(strval($field['name']), strval($field));
|
||||
}
|
||||
|
||||
return $solrDoc;
|
||||
}
|
||||
}
|
Loading…
Add table
editor.link_modal.header
Reference in a new issue