在 Sunspot Solr 中,我有一个模型Contact,我在 Solr 中建立索引。该Contact模型有很多属性,但我对其中两个进行了索引,:name并且:email. 为了防止每次Contact我们联系 Solr 中的字段发生更改时,我都会:ignore_attribute_changes_of在可搜索项上使用。
实际上,我只是想在更改:nameor时更新我的索引:email。我这样做:
fields = (Contact.attribute_names - ["name", "email"]).map{|o| o.to_sym}
searchable :ignore_attribute_changes_of => fields do
text :name
text :email
end
这对我来说似乎是错误的方式。有没有办法告诉 Sunspot searchable只更新某些属性的变化?也就是说,是否存在ignore_attribute_changes_of这种方式的反面或者是否有原因?