public static function getLuceneIndex() { ProjectConfiguration::registerZend(); if (file_exists($index = articuloTable::getLuceneIndexFile())) { return Zend_Search_Lucene::open($index); } else { return Zend_Search_Lucene::create($index); } }
public function updateLuceneIndex() { $index = articuloTable::getLuceneIndex(); $hit = $index->find('pk:' . $this->getId()); if ($hit) { $index->delete($hit->id); } $doc = new Zend_Search_Lucene_Document(); $doc->addField(Zend_Search_Lucene_Field::unIndexed('pk', $this->getId())); $doc->addField(Zend_Search_Lucene_Field::unStored('marca', $this->getMarca(), 'utf-8')); $doc->addField(Zend_Search_Lucene_Field::unStored('categoria', $this->getCategoria(), 'utf-8')); $doc->addField(Zend_Search_Lucene_Field::unStored('descripcion', $this->getDescripcion(), 'utf-8')); $index->addDocument($doc); $index->commit(); }