Ruby on rails 4 Model.solr\u搜索不适用于地理空间过滤器
我已经配置了Ruby on rails 4 Model.solr\u搜索不适用于地理空间过滤器,ruby-on-rails-4,solr,geospatial,sunspot-solr,Ruby On Rails 4,Solr,Geospatial,Sunspot Solr,我已经配置了太阳黑子-2.1.1 问题 我想搜索半径为20英里以内的所有产品,下面是我为产品型号搜索的代码 Product.search do fulltext(params[:search][:keyword]) order_by_geodist(:location, current_user.lat, current_user.lng) with(:location).in_radius(curren
太阳黑子-2.1.1
问题
- 我想搜索半径为20英里以内的所有产品,下面是我为
型号搜索的代码产品
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
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
我缺少什么,为什么它不在生产环境中工作,而在开发环境中工作
谢谢我真的很抱歉打开这个问题,我很愚蠢,因为我创建了
搜索\u controller\u backup.rb
,其中包含未配置地理空间
过滤功能的旧代码
问题是,一切正常,但由于rails正在从备份文件加载控制器代码,所以它看起来好像不正常
注意到这一点,以上两个代码都能完美地工作,没有任何问题……因此Model.solr\u search
与地理空间过滤器不工作无关
删除备份文件或将扩展名更改为非.rb
修复了我的问题