addObjects giving a fatal error when pushing data to algolia
index = Algolia::Index.new "YourIndex"
MyActiveRecordModel.find_in_batches(1000) do |objects|
index.add_objects(objects)
end
# that's actually what `MyActiveRecordModel.reindex!` does
mysql_connect('localhost', 'mysql_user', 'mysql_password');
mysql_set_charset('utf8');
$limit = 1000;
$start = 0;
$index = $client->initIndex('YourIndexName');
while (true) {
$q = mysql_query("SELECT * FROM YourTable LIMIT " . $start . "," . $limit);
$n = 0;
if ($q) {
$objects = array();
while(($row = mysql_fetch_assoc($q))) {
array_push($objects, $row);
++$n;
}
$index->addObjects($objects);
}
if ($n != $limit) {
break;
}
$start += $n;
}