Finding mongoDB records in batches (using mongoid ruby adapter)

后端 未结 6 1955
悲哀的现实
悲哀的现实 2020-12-14 00:32

Using rails 3 and mongoDB with the mongoid adapter, how can I batch finds to the mongo DB? I need to grab all the records in a particular mongo DB collection and index them

6条回答
  •  长情又很酷
    2020-12-14 01:13

    The following will work for you , just try it

    Model.all.in_groups_of(1000, false) do |r|
      Sunspot.index! r
    end
    

提交回复
热议问题