其实很奇怪。我有两个相互具有 has_many 关系的模型,这是我的模型
#model city
class City < ActiveRecord::Base
belong_to :state
end
#model state
class State < ActiveRecord::Base
has_many :city
end
我有状态索引
ThinkingSphinx::Index.define 'state', :with => :active_record do
indexes state_name, :sortable => true
#here is the problem
has "CRC32(cities.city_name)", :as => :city_name, :type => :integer
end
我想使用 city_name 作为过滤器。我上面的代码不起作用,运行时出现错误消息
rake ts:index
这是错误消息
ERROR: index 'state_core': sql_range_query: Unknown column 'cities.city_name' in 'field list'
但是,当我将 city_name 放在下面的索引块中时,索引器运行良好!
ThinkingSphinx::Index.define 'state', :with => :active_record do
indexes state_name, :sortable => true
indexes cities.city_name
has "CRC32(cities.city_name)", :as => :city_name, :type => :integer
end
有什么建议么 ?