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.
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
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' => '18.104.22.168' ]);
taskID of the indexing task to wait for.
default: No requestOptions
A list of request options to send along with the query.