如何(或可以)删除由zend_search_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";
    }
}

这是我在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);
}

最新更新