1

我继承了一个没有评论的 Zend 项目,也没有机会与之前的开发人员交谈。因为我没有 Zend 经验,所以我遇到了一些问题:)

我想在一个函数中打印出一些变量,该函数使用 Zend_Search_Lucene 对站点中的项目进行索引,因为我认为这里出了点问题。

根据我的阅读, ::create 创建一个新索引并 ::open 更新它。所以我想在这个 ::open 函数中打印出一些变量。

该函数的名称和参数如下。有谁知道如何调用这个函数以便我可以运行一些测试?

private function search($category,$string,$page = 1,$itemsByPage = 5)

编辑:或者,有没有一种方法可以删除现有索引并强制它完全重建,例如通过删除 FS 上的索引文件然后执行一些搜索?

4

2 回答 2

0

好例子——ZendFramework-1.9.6/demos/Zend/Search/Lucene

ZF 完整版

于 2009-12-21T19:40:27.800 回答
0

下面是一些从头开始创建索引的代码:

Zend_Search_Lucene_Analysis_Analyzer::setDefault(new StandardAnalyzer_Analyzer_Standard_English());

$tmpIndexDir = '/your/index/dir/'
$index = Zend_Search_Lucene::create($tmpIndexDir);

foreach($myObjects as $myObject){

    $doc = new Zend_Search_Lucene_Document();
    $doc->addField(Zend_Search_Lucene_Field::UnIndexed('objectId', $myObject->getId()));
    $contents = $myObject->toString();
    $contentsField = Zend_Search_Lucene_Field::Text('contents', $contents);
    $doc->addField($contentsField);
    $index->addDocument($doc);
}

$index->optimize();

...不记得我从哪里得到标准分析仪...

于 2009-12-21T19:28:02.160 回答