我在連接(中)表中有一列。我想在那列,它是位置思維獅身人面像排序順序無法按預期工作。
這裏是我的索引文件
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