solr search boost option rails 4 -


i trying implement solr search in rails 4.0 project.i have user , manufacturer model. user can have many manufacturers. in manufacturer model have rating field , name field. want apply solr search such if scoring 5 , if search query matches manufacturer name result should boost top.

i have given scores :

rating 1 => score 30 rating 2 => score 31 rating 3 => score 32 rating 4 => score 33 rating 5 => score 34 

how can achieve in rails?

i trying :

user.search   keywords(params[:query].strip)          boost(30.0) { with(:manufacturer_based_on_rating, params[:query].strip) }     boost(31.0) { with(:manufacturer_based_on_rating, params[:query].strip) }     boost(32.0) { with(:manufacturer_based_on_rating, params[:query].strip) }     boost(33.0) { with(:manufacturer_based_on_rating, params[:query].strip) }     boost(34.0) { with(:manufacturer_based_on_rating, params[:query].strip) }       end if params[:query].present? end.results 

and below searchable method :

searchable :auto_remove => false   text :manufacturer_based_on_rating |user|      user.manufactures.map{|m| m.name if m.present?} if user.manufacturers.present?   end end 


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -