【发布时间】:2016-08-08 15:42:59
【问题描述】:
有什么方法可以索引 STI 模型的类型(Ruby 中的多态模型关联)而不是它本身?比如我有一个模特Comment:
class Comment < ActiveRecord::Base
belongs_to :commenter, polymorphic: true
...
end
是否可以让 sphinx 索引 commenters 而不是 comments?
具体来说,不是sphinx.conf 的样子
source comment_core_0
{
...
sql_query = SELECT SQL_NO_CACHE comments.id * 60 + 2 AS id,
'Comment' AS sphinx_internal_class_name,
comments.id AS sphinx_internal_id,
'Comment' AS sphinx_internal_class
...
}
我希望sphinx.conf 看起来像:
source comment_core_0
{
...
sql_query = SELECT SQL_NO_CACHE comments.commenter_id * 60 + 2 AS id,
commenter_type AS sphinx_internal_class_name,
comments.commenter_id AS sphinx_internal_id,
commenter_type AS sphinx_internal_class
...
}
谢谢
【问题讨论】:
标签: ruby-on-rails ruby thinking-sphinx