def records_for_bulk_index(ids, batch_size = 1000)
      transaction do
        offset = 0
        ids.each_slice(batch_size) do |id_slice|
          records = where(:id => id_slice).all
          #yield records, offset
          yield where(:id => id_slice).all, offset
          offset += batch_size
        end
      end
    end
def records_for_bulk_index(ids, batch_size = 1000)
      transaction do
        offset = 0
        ids.each_slice(batch_size) do |id_slice|
          records = where(:id => id_slice).all
          #yield records, offset
          yield where(:id => id_slice).all, offset
          offset += batch_size
        end
      end
    end
yields the records with the given ids, in batches of batch_size