Hi,

 

Commit should be applied automatically when $index variable goes out of
scope... So, something is wrong. Could you prepare an example of code to
reproduce problem? 

 

PS TermDocs() should work faster for this purpose
(http://framework.zend.com/manual/en/zend.search.lucene.best-practice.ht
ml#zend.search.lucene.best-practice.unique-id):

--------------------------------------------------------

$config = new Zend_Config_Ini('./application/config.ini', 'search');

$index = Zend_Search_Lucene::open($config->index->path); 

 

$idTerm = new
Zend_Search_Lucene_Index_Term($this->_request->getParam('id'),
'comment_id');

$docIds  = $index->termDocs($term);

foreach ($docIds as $id) {

    $doc = $index->getDocument($idTerm);

    if ($doc->type == 'comment') {

        $index->delete($id);

    }

}

------------------------------------------------

 

With best regards,

   Alexander Veremyev.

 

________________________________

From: Vincent [mailto:[EMAIL PROTECTED] 
Sent: Saturday, October 06, 2007 9:35 AM
To: Rob Allen
Cc: fw-general@lists.zend.com
Subject: Re: [fw-general] Can't delete my index entries with
Zend_Search_Lucene

 

 

On 05/10/2007, Rob Allen <[EMAIL PROTECTED]> wrote:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Did you commit() after loop?


You see? I said so it would be a stupid mistake... Thanks! 

         

        Regards,
        
        Rob...
        
        Vincent wrote:
        > 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
        
        -----BEGIN PGP SIGNATURE-----
        Version: GnuPG v1.4.7 (MingW32)
        Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
        
        iD8DBQFHBgxz421+qn4cITwRAuz5AJ4nDMELOebWMPWRUDR8YjdoySVdLQCeN6mi
        e3KCrQkYaHtOTAquoK/2KO8=
        =vSHY
        -----END PGP SIGNATURE-----




-- 
Vincent 

Reply via email to