Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 4 Model.solr\u搜索不适用于地理空间过滤器_Ruby On Rails 4_Solr_Geospatial_Sunspot Solr - Fatal编程技术网

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
    
注意:上述代码在开发环境中正常工作,但在生产环境中不工作。我也尝试过为solr重新编制索引,但没有成功:(

我在搜索页面以外的页面中添加了以下代码,在该页面中,我正在显示基于radius的产品列表,并且它正在工作:

             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
修复了我的问题