如何(或我可以)删除Zend_Search_Lucene创建的索引文件

时间:2012-11-03 05:56:14

标签: php zend-framework lucene zend-search-lucene zend-lucene

有什么方法可以删除Zend_Search_Lucene创建的索引文件?如果不可能建议删除索引数据的方法。我已经从代码中尝试过了。但失败了。当我试图从Zend Studio删除索引文件时,它给出了一个错误,因为“资源与系统不同步”。我甚至无法从应用程序文件夹中执行此操作。请问,任何人都可以帮助我吗?

$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 个答案:

答案 0 :(得分:1)

这是我在UNIX服务器上的方式:

/**
 * 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);
}