如何调用Zend lucene搜索函数?

发布于 2024-08-14 07:33:03 字数 414 浏览 7 评论 0原文

我继承了一个没有注释的 Zend 项目,而且我没有机会与以前的开发人员交谈。由于我没有 Zend 经验,所以遇到了一些问题:)

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

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

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

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

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

I inherited a Zend project devoid of comments and I didn't get to talk to the previous developer. Since I have no Zend experience I'm having some issues :)

I'd like to print out some variables inside an function that indexes items from the site using Zend_Search_Lucene because I think something is going wrong here.

From what I've read, ::create creates a new index and ::open updates it. So it's in this ::open function I'd like to print out some variables.

The name and params of the function are below. Does anyone have any idea how this function can be called so I can run some tests?

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

EDIT: OR, is there a way I can nuke the existing index and force it to be rebuilt completely, for example by deleting the index files on the FS and then performing some searches?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

任性一次 2024-08-21 07:33:04

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

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();

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

Here's some code to create an index from scratch:

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();

... don't remember where i got the standard analyzer from...

黯然 2024-08-21 07:33:04

很好的例子 - ZendFramework-1.9.6/demos/Zend/Search/Lucene

ZF 完整发行版

good examples - ZendFramework-1.9.6/demos/Zend/Search/Lucene

ZF full distro

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文