如何阻止 ThinkingSphinx 查询数据库以分面 MVA 字段?
我设置了一个索引,这样我就可以对类别 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 来实现此目的?
谢谢!
I have a index set up so I can facet on category ids, as following:
define_index
...
has categorizings.category_id, :type => :multi, :facet => true
end
When I do a query like Listing.facets
, I get the correct results in a hash, with each category_id pointing at its count. :)
The only problem is Thinking Sphinx runs a database query and loads many (but not all) of these objects! Since this attribute is just MVA integers; I wouldn't think they would require any translation.
What's going on here? Is there any way for performance's sake I can stop Thinking Sphinx from instanciating all these ActiveRecord objects?(there can be hundreds!) Or is there a better way to achieve this with Sphinx and Thinking Sphinx?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来您可以使用 search_for_ids() 而不是主 search() 入口点,并思考 sphinx 仅返回结果的主键而不加载所有对象。
http://freelancing-god.github.com/ts/en/searching .html#ids
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