Search code examples
ruby-on-railsrubysolrsunspot

Can I instruct Solr (Sunspot) to skip reindexing for a block of code?


I'd like to run a series of interactions with various Searchable model records and not reindex any of the models until all of my interactions are completed. Is this possible?

I know I can manually call the reindexing method, but how do I manually instruct Sunspot to not reindex for a given block of code?


Solution

  • johnnycakes's answer was helpful, but since I needed to prevent automatic indexing entirely for a given model, I used the following instead:

    searchable :auto_index => false do
      text :name
      text :description
      # etc...
    end
    

    The :auto_index => false part is what instructs Solr to not index the model. Straightforward - but for some reason this took me a while to find via Google.