Check out example codes for "addObjects giving a fatal error when pushing data to algolia". It will help you in understanding the concepts better.

Code Example 1

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;
}

Code Example 2

$objects = [/* objects */];

$res = $index->saveObjects($objects, [
  'autoGenerateObjectIDIfNotExist' => true,
  'X-Forwarded-For' => '94.228.178.246'
]);

Code Example 3

$index->saveObjects(array objects, [
  "autoGenerateObjectIDIfNotExist" => boolean
  // any other requestOptions
]

// add a single object
$index->saveObject(array object, [
  "autoGenerateObjectIDIfNotExist" => boolean
  // any other requestOptions
]

Code Example 4

{
  "objectIDs": [
    "myObjectID1",
    "myObjectID2"
  ],
  "taskID": 678,
}

Code Example 5

$res = $index->saveObjects(
  [
    [
      'firstname' => 'Jimmie',
      'lastname'  => 'Barninger'
    ],
    [
      'firstname' => 'Warren',
      'lastname'  => 'Speach'
    ]
  ],
  [
    'autoGenerateObjectIDIfNotExist' => true
  ]
);

Code Example 6

{
  "objectID": "myObjectID1",
  "taskID": 678,
}

Code Example 7

$index->saveObjects(
  [
    [
      'objectID' => 'myID1',
      'firstname' => 'Jimmie',
      'lastname'  => 'Barninger'
    ],
    [
      'objectID' => 'myID2',
      'firstname' => 'Warren',
      'lastname'  => 'Speach'
    ]
  ]
);

Code Example 8

$index->saveObject(
  [
    'objectID' => 'myID',
    'firstname' => 'Jimmie',
    'lastname'  => 'Barninger'
  ]
);

Learn ReactJs, React Native from akashmittal.com