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

Commit

Permalink
Attempting to be a bit more efficient
Browse files Browse the repository at this point in the history
  • Loading branch information
bdmac committed Jan 4, 2012
1 parent 4c56078 commit 8f5574d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/sunspot/mongoid.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,14 @@ 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={})
0.step(count, 1000) do |offset|
0.step(count, 5000) do |offset|
records = []
limit(1000).skip(offset).each do |r|
limit(5000).skip(offset).each do |r|
records << r
end
Sunspot.index!(records)
Sunspot.index(records)
end
Sunspot.commit
end
end

Expand Down

0 comments on commit 8f5574d

Please sign in to comment.