我在连接(中)表中有一列。我想在那列,它是位置思维狮身人面像排序顺序无法按预期工作。
这里是我的索引文件
ThinkingSphinx::Index.define :restaurant, :with => :active_record, :delta => ThinkingSphinx::Deltas::DelayedDelta do
indexes schools.school_name, :sortable => true, :as => :school_name
indexes schools.branch_name, :sortable => true, :as => :branch_name
indexes contact_info.restaurant_name, :sortable => true, :as => :restaurant_name
indexes delivery_info.delivery_charges, :as => :delivery_charges
indexes restaurant_schools.position, :as => :restaurant_position, :sortable => true
has restaurant_info.is_pick_up, :as => :pick_up, :facet => true
has delivery_info.is_delivery, :as => :delivery, :facet => true
has schools.id, :as => :school_id, :facet => true
has restaurant_categories.id, :as => :restaurant_category_ids, :facet => true
has restaurant_info.min_order, :as => :min_order, :type => :float
has avg_rating, :as => :rating, :type => :integer
has ranking, :as => :ranking, :type => :integer
has delivery_info.delivery_estimated_time, :as => :delivery_eta, :type => :integer
set_property :min_infix_len => 1
end
当我做查询,例如搜索:
@restaurants = Restaurant.search :with => {:school_id => school_ids }
@restaurants = @restaurants.search :order => :restaurant_position
它不是给我的记录也应该如此。
请指教我应该怎样修复以获得准确的结果。
我有has_many通过协会,学校和餐馆之间。我想搜索是否给出了学校名称我需要按位置排列他们的餐厅(中间表字段) – Baran 2014-09-04 07:16:31
对,所以我在RestaurantSchool上搜索的建议听起来像是正确的方法。 – pat 2014-09-04 07:41:08