Wait for a task to finish
The
waitForTask
method is only available in thesearch
client context.
Some operations related to the Algolia index are not always instantaneous. Doing such operations with our API clients will provide a taskID
in the response body, so you can later know what is the status of your operation.
We provide a waitForTask
helper method for you to easily wait for a specific task status.
- C#
- Dart
- Go
- Java
- JavaScript
- Kotlin
- PHP
- Python
- Ruby
- Scala
- Swift
using Algolia.Search.Clients;
using Algolia.Search.Http;
var client = new SearchClient(new SearchConfig("YOUR_APP_ID", "YOUR_API_KEY"));
var response = await client.DeleteObjectAsync("<YOUR_INDEX_NAME>", "uniqueID");
await client.WaitForTaskAsync("<YOUR_INDEX_NAME>", response.TaskID);
import 'package:algolia_client_search/algolia_client_search.dart';
final client = SearchClient(appId: 'YOUR_APP_ID', apiKey: 'YOUR_API_KEY');
final response = await client.deleteObject(
indexName: "<YOUR_INDEX_NAME>",
objectID: "uniqueID",
);
await client.waitTask('<YOUR_INDEX_NAME>', response.taskID);
import "github.com/algolia/algoliasearch-client-go/v4/algolia/search"
client, err := search.NewClient("YOUR_APP_ID", "YOUR_API_KEY")
response, err := client.DeleteObject(client.NewApiDeleteObjectRequest(
"<YOUR_INDEX_NAME>", "uniqueID",
))
if err != nil {
// handle the eventual error
panic(err)
}
// use the model directly
print(response)
taskResponse, err := searchClient.WaitForTask("<YOUR_INDEX_NAME>", response.TaskID, nil, nil, nil)
if err != nil {
panic(err)
}
import com.algolia.api.SearchClient;
import com.algolia.model.search.*;
SearchClient client = new SearchClient("YOUR_APP_ID", "YOUR_API_KEY");
client.deleteObject("<YOUR_INDEX_NAME>", "uniqueID");
client.waitForTask("<YOUR_INDEX_NAME>", response.getTaskID());
import { searchClient } from '@algolia/client-search';
const client = searchClient('YOUR_APP_ID', 'YOUR_API_KEY');
const response = await client.deleteObject({
indexName: '<YOUR_INDEX_NAME>',
objectID: 'uniqueID',
});
// use typed response
console.log(response);
await client.waitForTask({ indexName: '<YOUR_INDEX_NAME>', taskID: response.taskID });
import com.algolia.client.api.SearchClient
val client = SearchClient(appId = "YOUR_APP_ID", apiKey = "YOUR_API_KEY")
var response = client.deleteObject(
indexName = "<YOUR_INDEX_NAME>",
objectID = "uniqueID",
)
// Use the response
println(response)
client.waitTask("<YOUR_INDEX_NAME>", response.taskID)
use Algolia\AlgoliaSearch\Api\SearchClient;
$client = SearchClient::create('<YOUR_APP_ID>', '<YOUR_API_KEY>');
$response = $client->deleteObject(
'<YOUR_INDEX_NAME>',
'uniqueID',
);
// play with the response
var_dump($response);
$client->waitForTask('<YOUR_INDEX_NAME>', $response['taskID']);
from algoliasearch.search.client import SearchClient
_client = SearchClient("YOUR_APP_ID", "YOUR_API_KEY")
response = await _client.delete_object(
index_name="<YOUR_INDEX_NAME>",
object_id="uniqueID",
)
# use the class directly
print(response)
# print the JSON response
print(response.to_json())
await client.wait_for_task(index_name="<YOUR_INDEX_NAME>", task_id=response.task_id)
require 'algolia'
client = Algolia::SearchClient.create('YOUR_APP_ID', 'YOUR_API_KEY')
response = client.delete_object("<YOUR_INDEX_NAME>", "uniqueID")
# use the class directly
puts response
# print the JSON response
puts response.to_json
client.wait_for_task("<YOUR_INDEX_NAME>", response.task_id)
import algoliasearch.api.SearchClient
val client = SearchClient(appId = "YOUR_APP_ID", apiKey = "YOUR_API_KEY")
val response = client.deleteObject(
indexName = "<YOUR_INDEX_NAME>",
objectID = "uniqueID"
)
// Use the response
val value = Await.result(response, Duration(100, "sec"))
client.waitTask("<YOUR_INDEX_NAME>", response.getTaskID())
import Search
let client = try SearchClient(appID: "YOUR_APP_ID", apiKey: "YOUR_API_KEY")
let response = try await client.deleteObject(indexName: "<YOUR_INDEX_NAME>", objectID: "uniqueID")
try await client.waitForTask(with: response.taskID, in: "<YOUR_INDEX_NAME>")