3

我设置了一个索引,因此我可以对类别 ID 进行分面,如下所示:

define_index
  ...

  has categorizings.category_id, :type => :multi, :facet => true
end

当我执行类似的查询时Listing.facets,我会在哈希中得到正确的结果,每个 category_id 都指向它的计数。:)

唯一的问题是 Thinking Sphinx 运行数据库查询并加载许多(但不是全部)这些对象!由于此属性只是 MVA 整数;我认为他们不需要任何翻译。

这里发生了什么?为了性能,有什么办法可以阻止 Thinking Sphinx 实例化所有这些 ActiveRecord 对象?(可能有数百个!)或者有没有更好的方法来使用 Sphinx 和 Thinking Sphinx 实现这一点?

谢谢!

4

1 回答 1

0

It looks like you can use search_for_ids() instead of the main search() entrypoint with thinking sphinx to return just the primary keys for your results and not load up all the objects.

http://freelancing-god.github.com/ts/en/searching.html#ids

于 2011-02-21T19:13:25.643 回答