I'm using Sunspot solr search in Rails application to list Users.
Users Controller :
def index
@users = User.search {
fulltext params[:search]
paginate :page => params[:page], :per_page => 10
}.results
end
User Model :
searchable do
text :email
text :user_profile do
user_profile.name
end
end
Whenever I update any User, the search results in two entries of the same record, visiting both will take me to the same record.
/users/1
Each time I need to run
rake sunspot:reindex[,User]
to fix this.
Is there a way where it returns only one entry, even after updating?
It would be really hard to find. But here are some options:
1) Make sure that you have 2 indexed records. Here some advices how to debug: Debugging Solr search queries on Sunspot
2) Look at config/sunspot.yml in order to see callbacks settings Github sunspot example There should be auto_remove_callback setting