Thinking Sphinx groups/collections 结果

Thinking Sphinx groups/collections of results

我正在尝试使用 TS 进行搜索,其中结果按属性分组(在示例中:类别)。

这样的结构(不一定是数组):

[[id: 1, name: this, category: foo] [id: 2, name: this, category: foo]],
[[id:3, name: this, category: bar], [id:4, name: this, category: bar]]

我想我可以得到按属性排序的结果,然后通过属性生成我想要的结构的结果,但我想看看是否可能是 TS 为我做这件事而没有使用 rails 遍历每个结果项。

我需要这个结构来显示按属性分类的结果元素。

我试过使用 GROUP_BY 但它 returns 每个属性只有 1 个元素,这让我觉得我要么不理解 GROUP_BY 要么我没有做查询权限:

Video.search(Search.build_options.merge({:conditions => {:name => "this"}, group_by: :category}))

我正在使用当前版本的 Sphinx 和 Thinking Sphinx,

正如 Barry 在他的评论中指出的那样,Sphinx 的分组方法是 return 每个分组属性值的一个记录,而不是该值的结果集合。因此,Thinking Sphinx 的行为也是如此。

如果你想要每个值的结果集合,你将不得不自己构建它 - 你绝对不能依赖 TS 为你做。