【问题标题】:rails sunspot solr not working with has_and_belongs_to_manyrails sunspot solr 不适用于 has_and_belongs_to_many
【发布时间】:2013-09-20 07:26:53
【问题描述】:

rails sunspot solr 不适用于 has_and_belongs_to_many

事件 -- has_and_belongs_to_many --tags

可搜索的 文本 :title, :boost => 5 文字:描述 文本:tag_names 做 标签.map(&:name) 结尾 结束

在上面的例子中,它只使用标题和描述。不带 tag_names。

【问题讨论】:

    标签: ruby-on-rails sunspot sunspot-rails sunspot-solr


    【解决方案1】:

    好吧,我在这里假设 tag_names 是一个数组。如果是这样,请给它这样...

    searchable do
      text :title, boost: 5 
      text :description
      text :tag_names, multiple: true do 
        tags.map(&:name)
      end 
    end
    

    (尝试使用新的哈希表示法...给出boost: 5 而不是:boost => 5.. 这只是一个建议.. 无论您遵循何种机制,您的代码都可以工作..)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-04-10
      • 2011-09-28
      • 2014-12-17
      • 2012-07-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多