【问题标题】:Boost listings with photos using Sunspot Solr使用 Sunspot Solr 增加带有照片的列表
【发布时间】:2014-07-09 20:17:31
【问题描述】:

我需要用照片增强 Foobars。我尝试了以下方法:

class Foobar < ActiveRecord::Base  
  searchable do
    text :full_name, :as => :full_name_textp
    boolean :photo do
      self.user.try(:avatar_file_name) != nil ? true : false
    end
    latlon(:location) { Sunspot::Util::Coordinates.new(latitude, longitude) }
    boost { :photo ? 1000 : 1 }
  end
end

当我重新索引 foobar 时,我没有收到任何错误,但是,当我搜索本地 foobar 时,带有照片的 foobar 不会被推到顶部。

【问题讨论】:

    标签: solr sunspot


    【解决方案1】:

    所以我无法弄清楚如何通过提升来实现这一点(不确定是否可能),但我能够同时声明 multiple sorters 以实现我正在寻找的结果。

    @dispensers = Dispenser.search do
      fulltext params[:search] 
      with(:location).in_radius(x, y, 15, :bbox => true)
      order_by(:photo, :desc)
    end
    

    【讨论】:

    • 您还可以在全文块内搜索期间进行提升:全文参数[:search] do boost(2.0) { with(:photo, true) } end
    猜你喜欢
    • 1970-01-01
    • 2013-08-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-31
    • 1970-01-01
    • 1970-01-01
    • 2011-07-10
    相关资源
    最近更新 更多