0
我已配置sunspot-2.1.1
。Model.solr_search不適用於地理空間過濾器
問題
我想搜索在20方圓百里所有的產品和下面是我的代碼做就是
Product
模型Product.search do fulltext(params[:search][:keyword]) order_by_geodist(:location, current_user.lat, current_user.lng) with(:location).in_radius(current_user.lat, current_user.lng, mile_to_km) paginate page: params[:page], per_page: GlobalConstant::SEARCH_RESULT_PER_PAGE end
注:上面的代碼在開發環境中正常工作,不在生產環境中工作。我試圖重新索引Solr的也有,但是沒有運氣:(
而且下面的代碼,我添加了除搜索頁面,在這裏我顯示基於半徑的產品清單和它工作:
Sunspot.search [Product] do
without(:sale_status, 'draft')
with(:user_id, current_user.id)
unless current_user.location.blank?
order_by_geodist(:location, current_user.lat, current_user.lng)
with(:location).in_radius(current_user.lat, current_user.lng, (mile_to_km))
end
paginate page: params[:page], per_page: GlobalConstant::TIMELINE_PER_PAGE
end
上午什麼我錯過了,爲什麼沒有在生產環境中工作,並正在努力在開發環境中它?
感謝