【问题标题】:Rails Sunspot solr search returns multiple entries of the same recordRails Sunspot solr 搜索返回同一记录的多个条目
【发布时间】:2016-03-02 16:58:02
【问题描述】:

我在 Rails 应用程序中使用 Sunspot solr 搜索来列出用户。

用户控制器:

def index
  @users = User.search { 
    fulltext params[:search]
    paginate :page => params[:page], :per_page => 10
  }.results
end

用户模型:

searchable do
  text :email

  text :user_profile do
    user_profile.name
  end
end

每当我更新任何用户时,搜索结果都会出现在同一记录的两个条目中,访问这两个条目会将我带到同一记录。

/users/1

每次我需要运行时

rake sunspot:reindex[,User]

解决这个问题。

有没有一种方法即使在更新之后也只返回一个条目?

【问题讨论】:

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


    【解决方案1】:

    真的很难找到。但这里有一些选择:

    1) 确保您有 2 个索引记录。这里有一些如何调试的建议:Debugging Solr search queries on Sunspot

    2) 查看 config/sunspot.yml 以查看回调设置 Github sunspot example 应该有 auto_remove_callback 设置

    【讨论】:

      猜你喜欢
      • 2012-05-23
      • 1970-01-01
      • 2013-09-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-28
      • 2012-05-24
      相关资源
      最近更新 更多