public function tearDown()
 {
     if ($this->documentImported) {
         $ids = Opus_Document::getAllIds();
         $last_id = array_pop($ids);
         $doc = new Opus_Document($last_id);
         $doc->deletePermanent();
     }
     parent::tearDown();
 }
예제 #2
0
define('APPLICATION_ENV', 'production');
// basic bootstrapping
require_once dirname(__FILE__) . '/../common/bootstrap.php';
$config = Zend_Registry::get('Zend_Config');
$host = $config->searchengine->solr->host;
$port = $config->searchengine->solr->port;
$baseUri = $config->searchengine->solr->path;
$EOL = "\n";
$commitRange = 100;
$solr = new Apache_Solr_Service($host, $port, $baseUri);
if (false === $solr->ping()) {
    echo 'Could not connect to solr service.' . $EOL;
    return;
}
$startTime = time();
$docIds = Opus_Document::getAllIds();
$documents = array();
$conf = Zend_Registry::get('Zend_Config');
$baseFilePath = null;
if (true === isset($conf->file->destinationPath) and true === is_dir($conf->file->destinationPath)) {
    $baseFilePath = $conf->file->destinationPath;
}
foreach ($docIds as $docId) {
    printMessage(' Indexing document : ' . $docId);
    $opusDoc = new Opus_Document($docId);
    $solrDocument = Qucosa_Search_Solr_Document_OpusDocument::loadOpusDocument($opusDoc);
    if (null !== $baseFilePath and 'published' === $opusDoc->getServerState()) {
        $files = $opusDoc->getFile();
        if (false === is_array($files)) {
            $files = array($files);
        }