public function testReindexAddons() { $mgr = new SolrSearch_Addon_Manager($this->db); $exhibit1 = $this->_exhibit(true, 'Exhibit 1', 'exhibit1'); $exhibit2 = $this->_exhibit(true, 'Exhibit 2', 'exhibit2'); $exhibit3 = $this->_exhibit(true, 'Exhibit 3', 'exhibit3'); $docs = $mgr->reindexAddons(); $this->assertCount(3, $docs); $this->assertInstanceOf('Apache_Solr_Document', $docs[0]); }
/** * This re-indexes everything in the Omeka DB. * * @return void * @author Eric Rochester **/ public static function indexAll($options = array()) { $solr = self::connect($options); $db = get_db(); $table = $db->getTable('Item'); $select = $table->getSelect(); // Removed in order to index both public and private items // $table->filterByPublic($select, true); $table->applySorting($select, 'id', 'ASC'); $excTable = $db->getTable('SolrSearchExclude'); $excludes = array(); foreach ($excTable->findAll() as $e) { $excludes[] = $e->collection_id; } if (!empty($excludes)) { $select->where('collection_id IS NULL OR collection_id NOT IN (?)', $excludes); } // First get the items. $pager = new SolrSearch_DbPager($db, $table, $select); while ($items = $pager->next()) { foreach ($items as $item) { $docs = array(); $doc = self::itemToDocument($item); $docs[] = $doc; $solr->addDocuments($docs); } $solr->commit(); } // Now the other addon stuff. $mgr = new SolrSearch_Addon_Manager($db); $docs = $mgr->reindexAddons(); $solr->addDocuments($docs); $solr->commit(); $solr->optimize(); }