1
我有兩個模型索引搜索(用戶和項目)。我試圖做模型之間的地理搜索:如何使用ThinkingSphinx對多個模型進行地理搜索?
ThinkingSphinx::Search.search('keywords', :geo => [ degrees_to_radians(params[:lat].to_f), degrees_to_radians(params[:lon].to_f) ], )
但我只得到一個錯誤:
Sphinx Error: index item_core,item_delta,user_core,user_delta: unknown latitude attribute ''
搜索每個模型單獨正常工作......但我我不知道這裏的問題是什麼。這裏有指標:
用戶索引:
define_index do
indexes [:first_name, :last_name], :as => :name
indexes login
indexes email
indexes headline
indexes description
indexes business.name, :as => :business_name
indexes [addresses.street_1, addresses.street_2, addresses.city, addresses.postal_code], :as => :address
has created_at, :sortable => true
has addresses.latitude, :as => :latitude, :type => :float
has addresses.longitude, :as => :longitude, :type => :float
set_property :delta => true
end
項目指標:
define_index do
indexes title, :sortable => true
indexes description
indexes [address.street_1, address.street_2, address.city, address.postal_code], :as => :address
indexes images.title, :as => :image_titles
indexes images.description, :as => :image_descriptions
indexes categories(:name), :as => :category_names
has price, :sortable => true
has created_at, :sortable => true
has address.latitude, :as => :latitude, :type => :float
has address.longitude, :as => :longitude, :type => :float
has categories(:id), :as => :category_ids
where "`items`.`state` = 'for_sale'"
set_property :delta => true
end