Api clients / Ruby / V1 / Methods

Wait for Operations | Ruby API Client V1 (Deprecated)

Deprecated content
This documentation is for a deprecated version of Ruby API client . Some features and settings may be missing or their usage may have changed. Refer to the documentation for the latest version of Ruby API client for up-to-date information.
Required API Key: any key with the addObject ACL
Method signature
index.wait_task(Integer taskID)

About this method

Wait for a task to complete before executing the next line of code, to synchronize index updates.

All write operations in Algolia are asynchronous by design.

It means that when you add or update an object to your index, our servers will reply to your request with a taskID as soon as they understood the write operation. The actual insert and indexing will be done after replying to your code. You can wait for a task to complete by using the `taskID’ and this method.

Check out our full discussion about asynchronous methods.

Examples

Wait for indexing of a new object:

1
2
3
4
5
6
$index->addObject(
  [
    'firstname' => 'Jimmie',
    'lastname'  => 'Barninger'
  ]
)->wait();

If you want to ensure multiple objects have been indexed, you need to check all taskIDs.

Wait for indexing of a new object and send extra http header

1
2
3
4
5
6
7
8
$index->addObject(
  [
    'firstname' => 'Jimmie',
    'lastname'  => 'Barninger'
  ]
)->wait([
  'X-Forwarded-For' => '94.228.178.246'
]);

Parameters

taskID
type: string
Required

taskID of the indexing task to wait for.

requestOptions
type: list
default: No requestOptions
Optional

A list of request options to send along with the query.

Response

No response.

Did you find this page helpful?