zend-frameworksearchlucenezend-lucene

Zend Lucene delete document


I have question about delete document in index file.

I have this:

$index = Zend_Search_Lucene::open('data/index');
foreach ($index->find('pk:' . $this->getId()) as $hit) {
        $index->delete($hit->id);
    }
$index->commit();

And I use Luke (It can open index file)

So before delete I see in my index entry. And after delete this entry still exist in index file, but in folder I see file for example _c0_del. So if this is normal, that after delete I can see my entry in index file? Or there is some error in my code? I try make

 var_dump($segmentInfo->delete($id - $segmentStartId));

In ZendSearch / library / ZendSearch / Lucene / Index.php in delete method. And it give me null. Is it normal? If delete method physical remove document from index or just set flag that this document isDeleted? I use lucene maybe 2 years ago, and It physical remove document from index file. So after delete I can't see my entry in index through Luke.


Solution

  • If Luke does not show your deleted document, then even if the document is still in the index it will not matter -- the deleted document has been removed from consideration by the Lucene search engine and will be physically removed later in the indexing process.