This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run with: rake environment elasticsearch:reindex | |
namespace :elasticsearch do | |
desc "re-index elasticsearch" | |
task :reindex => :environment do | |
klass = Place | |
ENV['CLASS'] = klass.name | |
ENV['INDEX'] = new_index = klass.tire.index.name << '_' << Time.now.strftime('%Y%m%d%H%M%S') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Custom reindexing with Sunspot | |
# Use your own finder, rescue and log exceptions, etc. | |
# Throw this in a rake task, or class method to run from the console | |
Article.find_in_batches(:batch_size => 100) do |articles| | |
articles.each do |article| | |
tries = 0 | |
begin | |
article.solr_index | |
rescue RSolr::RequestError => e |
NewerOlder