Skip to content
This repository was archived by the owner on Oct 23, 2018. It is now read-only.

Commit

Permalink
Modified solr_index method to work with large collections better
Browse files Browse the repository at this point in the history
  • Loading branch information
bdmac committed Jan 4, 2012
1 parent 6ace9a7 commit db8ff74
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/sunspot/mongoid.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ module ClassMethods
# The sunspot solr_index method is very dependent on ActiveRecord, so
# we'll change it to work more efficiently with Mongoid.
def solr_index(opt={})
Sunspot.index!(all)
0.step(count, 1000) do |offset|
records = limit(1000).skip(offset).to_a
Sunspot.index!(records)
end
end
end

Expand Down

0 comments on commit db8ff74

Please sign in to comment.