使用Solr_search查询备用记录轨道

时间:2016-01-12 12:48:10

标签: mysql ruby-on-rails solr

我目前正在使用此代码:

    @all ||= Job.solr_search do
     fulltext params[:term]
     with(:location).in_radius(location[0], location[1], 15) if location.present?
     with(:job_type, params[:job_type])                      if params[:job_type].present?
     with(:sector, params[:sector])                          if params[:sector].present?
     with(:department, params[:department])                  if params[:department].present?
     with(:schedule, params[:schedule])                      if params[:schedule].present?
     with(:study_level, params[:study_level])                if params[:study_level].present?
     with(:field_of_study, matched_fields_of_study)          if params[:fields_of_study].present?
     with(:active, true)
     with(:application_type, params[:application_type])      if params[:application_type].present?
     with(:origin, params[:origin])                          if params[:origin].present?
     order_by_geodist(:location, location[0], location[1]) if location.present?
     paginate(:page => params[:page], :per_page => params[:per_page])
    end

用于查询Job表并显示:

Job 1, origin = 3
Job 2, origin = 3
Job 3, origin = 3
Job 4, origin = 3
Job 6, origin = 2
Job 7, origin = 2
Job 8, origin = 3
Job 9, origin = 3
Job 10, origin = 1

我要求能够显示这样的工作:

Job 1, origin = 1
Job 2, origin = 2
Job 3, origin = 3
Job 4, origin = 1
Job 6, origin = 2
Job 7, origin = 3
Job 8, origin = 1
Job 9, origin = 2
Job 10, origin = 3

所以我每次都根据出生地的工作进行交替。 这怎么可能 ?如果是的话。

我使用Rails,Solr& MySQL的

由于

0 个答案:

没有答案