Solr重新索引与关联

时间:2014-06-05 17:18:24

标签: ruby-on-rails-3 solr

我的模型中有以下代码:

has_many :links
 searchable do
    text :name, :as => :name_textp
    integer :membership_ordering
    text :business_description, :stored => true
    text :tags do
      tags.map(&:name)
    end
    text :links_name do
      company_links.map(&:name)
    end    
    text :links_description do
      company_links.map(&:description)
    end
    text :links_tags do
      links.map(&:tags_text) 
    end
  end

当出于某种原因我更新模型时,Solr会自动将更改添加到索引中。但是当我更新links时,似乎它没有直到我手动调用太阳黑子:solr:reindex。我还在协会中添加了以下代码:

  searchable do
    text :name
    text :description
    text :tags_text
  end

但我无法让它发挥作用。我还需要做什么?

1 个答案:

答案 0 :(得分:0)

你是从头开始安装solr还是用bundle install command安装solr 请看一下这个程序,我认为这将使你的ruby / solr配置工作。 首选启动solr:

bundle exec rake sunspot:solr:start
bundle exec rake sunspot:reindex

享受:)

更新6/06 1H49 BRT 您是否在solrconfig.xml中设置了自动提交:

<autoCommit> 
  <maxDocs>10000</maxDocs>
  <maxTime>20000</maxTime>
</autoCommit>

更新6/06 9H41 BRT 请看一下这篇文章:sunset not reindexing这似乎是一个常见问题。 可以通过执行提交来覆盖。 正如dzone所说:

  

你需要定期使用太阳黑子重建索引。