0

我有 2 个模型用户和讨论。我定义了模型的索引如下:
对于用户模型:

define_index do
indexes email
indexes first_name
indexes last_name, :sortable => true
indexes groups(:name), :as => :group_names
has "IF(email_confirmed = true and status = 'approved', true, false)", :as => :approved_user, :type => :boolean
has "IF(email_confirmed = true and (status = 'approved' or status='blocked'), true, false)", :as => :approved_or_blocked_user, :type => :boolean
has points, :type => :integer
has created_at, :type => :datetime
has user(:id)
set_property :delta => true
end

对于讨论模型:

define_index do
indexes title
indexes description
indexes category(:title), :as => :category_title
indexes tags(:title), :as => :tag_title
has "IF(publish_to_blog = true AND sticky = false, true, false)", :as => :publish_to_main, :type => :boolean
has created_at
has updated_at, :type => :datetime
has recent_activity_at, :type => :datetime
has views_count, :type => :integer
has featured
has publish_to_blog
has sticky
set_property :delta => true
end

根据文档,我已在两个表中添加了一个增量列。我的问题是增量索引仅适用于 Discussion 模型而不适用于 User 模型。例如:当我更新讨论的“标题”时,我可以看到思考的狮身人面像正在旋转索引等(从日志中可以明显看出)。但是当我更新用户的 'first_name' 或 'last_name' 时,什么也没有发生。

User 模型还有一个 has_many :through 关联,通过一个名为 GroupsUser 的模型。我在 GroupsUser 上设置了 after_save,如下所示:

def set_user_delta_flag
user.delta = true
user.save
end

即使这似乎也不会触发用户模型上的增量索引。讨论模型的类似设置完美运行!谁能告诉我为什么会这样?

4

1 回答 1

0

好吧,我想通了。问题出在属性定义上:

has user(:id)

当我从定义中删除它并运行重建时,一切似乎都运行良好。

于 2010-04-09T20:56:15.873 回答