Skip to content

Commit

Permalink
Attempting to be a bit more efficient
Browse files Browse the repository at this point in the history
  • Loading branch information
bdmac authored and Empact committed Mar 26, 2012
1 parent 3620234 commit 5d379c6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/sunspot/mongoid.rb
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

def solr_index_orphans(opts={})
Expand Down

0 comments on commit 5d379c6

Please sign in to comment.