如何搜索有太阳黑子和太阳黑子的树索尔
我有一个看起来像这样的模型
class Post
acts_as_tree
end
我想做的是对整个帖子线程的内容进行搜索,但只返回结果中的父帖子,并对这些结果进行分页。
我读过有关 sunspot/solr 中的facets 的内容,虽然这确实返回了正确的结果,但它们无法分页。
基本上,我想搜索一组帖子,但按其 parent_id
进行分组。这在 sunspot/solr 中可能吗?
I have a model that looks something like this
class Post
acts_as_tree
end
What I want to do is conduct a search on the contents of an entire thread of posts, but only return the parent post in the results, and paginate these results.
I've read about facets in sunspot/solr, and while this does return the correct results, they cannot be paginated.
Basically, I want to search a set of posts, but group by their parent_id
. Is this possible in sunspot/solr?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您基本上想要搜索由线程的所有子节点组成的字段。您可以使用 sunspot 的块语法来做到这一点。如果帖子是根节点,则索引该节点的所有子节点(您必须实现 all_children,这应该不会太难)。
然后搜索这个“帖子”文本字段。由于您只为根节点索引了任何内容,因此这些是结果集中将返回的唯一对象。
You basically want to search over a field that is composed of all of a thread's child nodes. You can do this with sunspot's block syntax. If the post is a root node, index all of the node's children (you'll have to implement all_children, which shouldn't be too hard).
Then search over this "posts" text field. Since you only indexed anything for root nodes, these are the only objects that will be returned in your result set.