Search code examples
mysqlruby-on-railssolrreportsunspot-solr

Report Reindex taking too long after destroy


I have an product report that lists all products registered. When i destroy(delete) one of items from de product list i need the item to be removed from the report list. I do use Sunspot Solr with Mysql. I tried the following way:

after_destroy { ProductsReport.reindex; Sunspot.commit }

But because of my gigantic list of products it takes too long to execute. Is that a simple or more performing way to do it?

By the way, my system is built in Ruby on Rails. Thanks in advance.


Solution

  • The previous answer is correct - instead of reindexing, you should only remove the document in question from Solr, There is no need to reindex all the documents if only one document has changed.

    In Sunspot you do can do this with Sunspot.remove(Doc).