Question

I am working on a rails project that involves the solr sunspot gem. I left the default behavior to auto update the index on model saves, but I was wondering if there was a way to temporarily disable the indexing when mass creating objects, such as during a rake db:seed process. When using the seed command I was hoping it would add all of the objects and then perform one big reindex call to update the entire table. Any ideas?

Thanks!

Was it helpful?

Solution

You could set Sunspot's session to a StubSessionProxy.

OTHER TIPS

There's also this.

Basically, you should be able to add this to sunspot.yml:

development:
    disabled: true

This works great if you're running some tasks or queries directly on the DB. However, if you are running your app with this setting, and anywhere in your code you have something like:

Sunspot.config.pagination.default_per_page = 50

Then you'll hit an error like this:

undefined method `config' for #<Sunspot::Rails::StubSessionProxy:0x007ff6ee33df28>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top