Hello,

I am currently working on this website where users can add comments to
messages. At the moment I am trying to allow the admin to delete these
comments. However, the code I use can't seem to delete this comment from my
search index. I've been struggling with it for a while now and just can't
seem to find the answer, so I was hoping to find help here.

This is my current code:

                $config = new Zend_Config_Ini('./application/config.ini',
'search');
                $index = Zend_Search_Lucene::open($config->index->path);
                $query = new Zend_Search_Lucene_Search_Query_MultiTerm();
                $query->addTerm(new
Zend_Search_Lucene_Index_Term($this->_request->getParam('id'),

'comment_id'), true);
                $query->addTerm(new Zend_Search_Lucene_Index_Term('comment',
'type'), true);
                $hits = $index->find($query);
                foreach($hits as $hit)
                {
                    $index->delete($hit->id);
                }

The opening of the index works as it should, and it even is able to find my
comments (I'm able to do an echo $hit->comment_id within the foreach loop,
however, $index->delete($hit->id) doesn't delete the entry. I'm probably
doing something incredibly stupid here, so I hope that you will be able to
help me.

Thanks in advance,

-- 
Vincent

Reply via email to