如何让 zend_lucene 和 zend_paginator 工作
我使用 Zend Framework 已有几个月了。所以,我的知识很好,但还不是专家。我正在尝试将 zend_lucene 与 zend_paginator 一起使用,但到目前为止尚未成功。我能够成功地使用 zend_lucene 和索引数据本身,并且能够在查询数据库时使用 zend_paginator,但我似乎无法将两者结合起来。这是我正在做的事情的示例:
尝试 { $searchresults = $index->find($lucenequery); } 捕获(Zend_Search_Lucene_Exception $e){ echo "无法{$e->getMessage()}"; }
$page = $this->_getParam('page',1);
$paginator = Zend_Paginator::factory($searchresults);
$paginator->setItemCountPerPage(20);
$paginator->setCurrentPageNumber($page);
$this->view->paginator = $paginator;
我需要对 lucene 和 zend_paginator 执行不同的步骤吗?我真的很不确定。我得到的结果是第一页结果显示正确。但是当我点击第二页或第三页时,我的结果是空白的。不确定可能出了什么问题,因为我找不到将两者一起使用的文档或教程。任何帮助将不胜感激。
I've been using Zend Framework for a few months now. So, my knowledge is pretty good but I'm not quite an expert yet. I am trying to use zend_lucene with zend_paginator and so far not successful. I am able to use zend_lucene and index data successfully by itself and able to do use zend_paginator when querying the database, but I can't seem to combine the two. Here is a sample of what I am doing:
try {
$searchresults = $index->find($lucenequery);
}
catch (Zend_Search_Lucene_Exception $e) {
echo "Unable {$e->getMessage()}";
}
$page = $this->_getParam('page',1);
$paginator = Zend_Paginator::factory($searchresults);
$paginator->setItemCountPerPage(20);
$paginator->setCurrentPageNumber($page);
$this->view->paginator = $paginator;
Is there a different step I need to do with lucene and zend_paginator? I am really uncertain. The result I get is that for the first page results display properly. But when I hit the second page or third my results are blank. So uncertain what might be wrong as I can't find docs or tutorials in using the two together. Any help would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为这可能适用于迭代器适配器:
也许您遇到的问题是 $paginator 不知道有多少搜索结果。
所以您可能需要手动执行此操作:
I think this may work with the iterator adapter:
Perhaps the problem you are having is that $paginator doesn't know how many search results there are..
So you may need to do that manually: