Background search indexing using existing worker systems.
$ gem install sunspot-queueIn your Gemfile
gem "sunspot-queue"
gem "resque"In config/initializers/sunspot.rb
require "sunspot/queue/resque"
backend = Sunspot::Queue::Resque::Backend.new
Sunspot.session = Sunspot::Queue::SessionProxy.new(Sunspot.session, backend)Start Resque
$ QUEUE=sunspot rake resque:workIn your Gemfile
gem "sunspot-queue"
gem "sidekiq"In config/initializers/sunspot.rb
require "sunspot/queue/sidekiq"
backend = Sunspot::Queue::Sidekiq::Backend.new
Sunspot.session = Sunspot::Queue::SessionProxy.new(Sunspot.session, backend)Start Sidekiq
$ sidekiq -q sunspotIn your Gemfile
gem "sunspot-queue"
gem "delayed_job"
gem "delayed_job_active_record" # or choose another backendIn config/initializers/sunspot.rb
require "sunspot/queue/delayed_job"
backend = Sunspot::Queue::DelayedJob::Backend.new
Sunspot.session = Sunspot::Queue::SessionProxy.new(Sunspot.session, backend)Start Delayed::Job
$ rake jobs:work In config/initializers/sunspot.rb
Sunspot::Queue.configure do |config|
# Override default job classes
config.index_job = CustomIndexJob
config.removal_job = CustomRemovalJob
endThe sunspot-queue jobs update the Solr index but those changes don't appear in search results until Solr commits those changes. Solr supports automatically commiting changes based on either the number of changes and / or time between commits.
Add (or uncomment) the following in solrconfig.xml
<autoCommit>
<maxDocs>10000</maxDocs>
<maxTime>30000</maxTime>
</autoCommit>See Solr's documentation for more information.
- Fork the project.
- Add tests to show the problem or test your feature
- Make your feature addition or bug fix.
- Send me a pull request. Bonus points for topic branches.
Please don't make changes to the Rakefile, version, or history.
$ gem install bundler
$ bundle
$ guardSee LICENSE for details.
