如何管理“分页"与索尔? [英] How to manage "paging" with Solr?
问题描述
我有一个分类广告网站...我让 Solr 搜索分类广告,然后返回 ID:nrs,然后我将其放入一个数组中.然后我使用这个数组在 MySql 数据库中查找任何分类,其中 ID:s 与 Solr 返回的数组中的 ID:s 匹配.
I have a classifieds website... I have Solr doing the searching of the classifieds, and then return ID:nrs which I then use to put into an array. Then I use this array to find any classifieds in a MySql db where the ID:s match the ID:s in the array returned by Solr.
现在,因为这个数组可能非常大(10 万条记录或更多),所以我需要分页"结果,以便一次返回 100 个.然后在 MySql 中使用这 100 个 ID:s 来查找分类信息.
Now, because this array can be very very big (100thousand records or more) then I would need to "page" the results so that maybe 100 where returned at a time. And then use those 100 ID:s in MySql to find the classifieds.
那么,是否可以使用 SOLR 进行分页?
So, is it possible to page with SOLR?
如果是这样,怎么办?我需要示例代码...结果会是什么.
And if so, how? I need example code... And what the results would be please.
主要是我需要一个完整的例子!
Mostly I need a thorough example!
谢谢
推荐答案
看看 IBM.也许这会让你走上正确的道路.
Take a look at IBM. Maybe that will get you on the right course.
结果数:指定返回的最大结果数.
Number of results: Specifies the maximum number of results to return.
Start:结果集中开始的偏移量.这对于分页很有用.
Start: The offset to start at in the result set. This is useful for pagination.
所以你可能想要一些变化
So you probably want some variation on
<str name="rows">10</str>
<str name="start">0</str>
您的 solr 客户端应该提供一些方法来轻松获得结果总数.
Your solr client should provide some way to get the total number of results without much trouble.
这篇关于如何管理“分页"与索尔?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!