Wait for operations
Required API Key:
any key with the
addObject
ACL
index.saveObject(...).waitTask(); index.saveObjects(...).waitTask(); index.partialUpdateObject(...).waitTask(); index.partialUpdateObjects(...).waitTask(); index.replaceAllObjects(...).waitTask(); index.deleteObject(...).waitTask(); index.deleteObjects(...).waitTask(); index.deleteBy(...).waitTask(); index.clearObjects(...).waitTask(); index.setSettings(...).waitTask(); index.saveSynonym(...).waitTask(); index.saveSynonyms(...).waitTask(); index.replaceAllSynonyms(...).waitTask(); index.deleteSynonym(...).waitTask(); index.clearSynonyms(...).waitTask(); index.saveRule(...).waitTask(); index.saveRules(...).waitTask(); index.replaceAllRules(...).waitTask(); index.deleteRule(...).waitTask(); index.clearRules(...).waitTask(); client.moveIndex(...).waitTask(); client.copyIndex(...).waitTask(); client.copyRules(...).waitTask(); client.copySynonyms(...).waitTask(); client.copySettings(...).waitTask(); client.addApiKey(...).waitTask(); client.updateApiKey(...).waitTask(); client.deleteApiKey(...).waitTask(); client.multipleBatch(...).waitTask();
You’re currently reading the JavaScript API client v4 documentation. Check the migration guide to learn how to upgrade from v3 to v4. You can still access the v3 documentation.
You’re currently reading the Ruby API client v2 documentation. Check the migration guide to learn how to upgrade from v1 to v2. You can still access the v1 documentation.
About this method # A
Wait for a task to complete to ensure synchronized index updates.
All Algolia write operations are asynchronous.
When you make a request for a write operation, for example, to add or update records in your index, Algolia creates a task on a queue and returns a taskID
.
The task itself runs separately, depending on the server load.
You can wait for a write operation to complete by using the task’s taskID
and the waitTask
method.
Examples # A
Read the Algolia CLI documentation for more information.
Wait until a new object is added to an index#
1
2
3
4
5
6
7
BatchIndexingResponse resp = index.saveObject(
new Contact().setFirstname("Jimmie").setLastname("Barninger")
);
// All objects implementing the AlgoliaWaitableResponse interface
// Can be awaited with the .waitTask() method
resp.waitTask();
If you want to ensure multiple objects have been indexed, you must check all taskID
s.
Wait for indexing of a new object and send extra http header#
1
2
3
4
5
6
7
8
BatchIndexingResponse resp = index.saveObject(
new Contact().setFirstname("Jimmie").setLastname("Barninger"),
new RequestOptions().addExtraHeader("X-Algolia-User-ID", "user123")
);
// All objects implementing the AlgoliaWaitableResponse interface
// Can be awaited with the .waitTask() method
resp.waitTask();
Parameters # A
Response # A
This method doesn't return a response.