How to(or Can I) delete the index file created by Zend_Search_Lucene

134 Views Asked by At

Is there any way by which I can delete the index file created by the Zend_Search_Lucene? If its not possible kindly suggest a method to delete the indexed data. I've tried it from the code. But failed. And when I tried to delete the index file from the Zend Studio its giving me an error as "Resource is out of sync with the system". I couldn't even do it from the applications folder. Please, can any one help me?

$hits = $index->find('path:' . $indexpath);
foreach ($hits as $key =>$hit) 
{
    $index->delete($key);
}
$indexSize = $index->count();
$documents = $index->numDocs();
for ($count = 0; $count < $index->maxDoc(); $count++) 
{
    if ($index->isDeleted($count)) 
    {
       echo "Document deleted.\n";
    }
}
1

There are 1 best solutions below

0
tasmaniski On

This is my way on UNIX server:

/**
 * Delete whole Index, get $PATH_TO_INDEX from constant
 *
 * @return the last line of the command output or FALSE on failure
 */
public function deleteIndex(){
    $command = "rm -R ".$PATH_TO_INDEX;
    return system($command);
}