Guest User

Untitled

a guest
Jan 24th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. # Custom reindexing with Sunspot
  2. # Use your own finder, rescue and log exceptions, etc.
  3. # Throw this in a rake task, or class method to run from the console
  4.  
  5. Article.find_in_batches(:batch_size => 10) do |articles|
  6. articles.each do |article|
  7. tries = 0
  8. begin
  9. article.solr_index
  10. rescue RSolr::RequestError => e
  11. puts "ERROR - #{e.message} on #{article.inspect}"
  12. if (tries += 1) < 3
  13. sleep 2 ** tries
  14. retry
  15. end
  16. end
  17. end
  18. end
Add Comment
Please, Sign In to add comment