/** * Add a document to the index. * * @return void * @access private * @static * * @author Etienne de Longeaux <*****@*****.**> * @since 2012-06-11 */ public static function addDocument() { // Search for documents with the same Key value. $term = new \Zend_Search_Lucene_Index_Term(self::$_doc->Key, 'Key'); $docIds = self::$_index->termDocs($term); // Delete any documents found. foreach ($docIds as $id) { self::$_index->delete($id); } if (self::$_doc instanceof \Zend_Search_Lucene_Document) { self::$_index->addDocument(self::$_doc); } }
/** * Deletes an indexed page. * * @param \Sfynx\CmfBundle\Entity\Page * @return void * @access public * * @author Etienne de Longeaux <*****@*****.**> * @since 2012-06-11 */ public function deletePage(\Sfynx\CmfBundle\Entity\Page $page) { // Open the index self::open($this->_indexPath); // Search for documents with the same route_name. $hits = self::$_index->find('Route:' . $page->getRouteName()); // Delete any documents found. foreach ($hits as $hit) { self::$_index->delete($hit->id); //print_r($hit->getDocument()->Route); //print_r('<br />'); } // Commit the index self::commit(); }