0

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";
    }
}
hakre
  • 193,403
  • 52
  • 435
  • 836
harry
  • 1,410
  • 3
  • 12
  • 31

1 Answers1

1

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);
}
tasmaniski
  • 4,767
  • 3
  • 33
  • 65