egeloen / IvoryLuceneSearchBundle

Provides a Zend Lucene Search integration for your Symfony2 project.
MIT License
29 stars 11 forks source link

Delete is not working... #3

Closed amarrella closed 12 years ago

amarrella commented 12 years ago

Hi there, i have a problem with index delete... Here is the portion of code involved:

class VideogameAdmin extends Admin {

//other controllers...

public function postRemove($object)
{

$index = $this->configurationPool->getContainer()->get('ivory_lucene_search')->getIndex('indice'); foreach ($index->find('pk:'.$object->getId()) as $hit) { $index->delete($hit->id); } }

}

Can you help me please? Thanks in advance, Alessandro

egeloen commented 12 years ago

Have you commit your change ?

Try :

public function postRemove($object)
{
    $index = $this->configurationPool->getContainer()->get('ivory_lucene_search')->getIndex('indice');

    foreach ($index->find('pk:'.$object->getId()) as $hit) {
        $index->delete($hit->id);
    }

    $index->commit();
}
amarrella commented 12 years ago

I resolved the issue trying your code in preRemove controller (not in postRemove) and IT WORKS!

Thank you very much for your reply, Alessandro

egeloen commented 12 years ago

You're welcome :)