*/ if (!isset($argv[1])) { die('No delete file specified'); } require_once 'util.inc.php'; // set up util environment require_once 'File/MARC.php'; require_once 'sys/Solr.php'; // Read Config file $configArray = parse_ini_file('../web/conf/config.ini', true); // Setup Solr Connection $url = $configArray['Index']['url']; $solr = new Solr($url); if ($configArray['System']['debugSolr']) { $solr->debug = true; } // Parse delete.mrc file $collection = new File_MARC($argv[1]); // Iterate through the retrieved records $i = 0; while ($record = $collection->next()) { $idField = $record->getField('001'); $id = $idField->getData(); $solr->deleteRecord($id); $i++; } // Commit and Optimize if ($i) { $solr->commit(); $solr->optimize(); }
function removeFromSolr() { require_once ROOT_DIR . '/sys/Solr.php'; global $configArray; $host = $configArray[$this->getConfigSection()]['url']; global $logger; $logger->log("Deleting Record {$this->solrId()}", PEAR_LOG_INFO); $cores = $this->cores(); foreach ($cores as $corename) { $index = new Solr($host, $corename); if ($index->deleteRecord($this->solrId())) { $index->commit(); } else { return new PEAR_Error("Could not remove from {$corename} index"); } } return true; }