“复杂”使用太阳黑子进行分组和排序
我有一个问题,我似乎无法找到解决方案。
我想实现以下目标:
* 我有一个任务列表,每个任务都有一个所有者和截止日期
* 我想显示按所有者分组的所有任务的列表
* 我想根据到期日对所有者进行排序:例如,首先是到期日最低的所有者,然后是到期日第二低的所有者,等等
为了说明这一点,这将是我正在寻找的结果:
Harry
- 任务 1,截止日期 1
- 任务 3,截止日期 4
本
- 任务 2,截止日期 2
卡罗尔
- 任务 4,截止日期 3
我正在使用 sunspot 来搜索和过滤结果,所以理想情况下我想使用 sunspot 来执行此操作。我一直在尝试通过方面和排序获得结果,但尚未得到此结果(我可以按所有者分组,或按截止日期排序,但不能两者兼而有之)。
任何帮助将不胜感激。
欧文
I have a problem to which I can't seem to find a solution.
I want to achieve the following:
* i have a list of tasks, each with an owner and a due date
* i want to display a list of all tasks grouped by owner
* i want to sort the owners based on the due dates: e.g. The owner with the lowest due date first, followed by the owner with the second lowest, etc
To ilustrate, this would be a result i am looking for:
Harry
- task 1, due date 1
- task 3, due date 4
Ben
- task 2, due date 2
Carol
- task 4, due date 3
I am using sunspot to search and filter results, so ideally i would like to use sunspot to do this. I've been trying to get the results with facets and ordering but haven't gotten this result to work yet(i can group by owners, or order by due date just not both).
Any help would be appreciated.
Erwin
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您想要使用的是solr的结果分组/字段折叠功能。
不幸的是,这是 solr 中的一个相当新的功能,并且 sunspot(自 1.3.0 起)。但是,它正在积极开发中,并明确列为“未来版本”的功能。这可能很快就会发生,因为几天前刚刚提交了此功能的拉取请求。
如果您还没有找到解决方法,您可以从该拉取请求中获取代码,看看它是否满足您的需要......走在前沿总是很有趣,对吗? :)
更新:对字段分组的支持刚刚合并到 sunspot 的主分支中。 查看一下。太阳黑子的自述文件已更新,其中包含如何准确执行您想要执行的操作的示例。
What you want to use is the Result Grouping/Field Collapsing feature of solr.
Unfortunately, this is a fairly new feature in solr, and isn't yet supported in sunspot (as of 1.3.0). However, it is under active development and explicitly listed as a feature for a "future release". This might be soon-ish, as a pull request for this feature was just submitted a couple days ago.
If you haven't found a workaround, you could grab the code from that pull request and see if it does what you need it to do....always fun to walk on the bleeding edge, right? :)
UPDATE: Support for field grouping was just merged in to the master branch of sunspot. Check it out. The readme for sunspot has been updated with examples of how to do exactly what you're trying to do.