In this tutorial, you’ll use the Meilisearch API to add documents to an index, and then monitor its status.
Many Meilisearch operations are processed asynchronously in a task. Asynchronous tasks allow you to make resource-intensive changes to your Meilisearch project without any downtime for users.In this tutorial, you’ll use the Meilisearch API to add documents to an index, and then monitor its status.
Operations that require indexing, such as adding and updating documents or changing an index’s settings, will always generate a task.Start by creating an index, then add a large number of documents to this index:
The summarized task object is confirmation your request has been accepted. It also gives you information you can use to monitor the status of your request, such as the taskUid.
You can add documents to a new Meilisearch Cloud index using the Cloud interface. To get the taskUid of this task, visit the “Task” overview and look for a “Document addition or update” task associated with your newly created index.
Meilisearch processes tasks in the order they were added to the queue. You can check the status of a task using the Meilisearch Cloud interface or the Meilisearch API.
Monitoring task status in the Meilisearch Cloud interface
Log into your Meilisearch Cloud account and navigate to your project. Click the “Tasks” link in the project menu:This will lead you to the task overview, which shows a list of all batches enqueued, processing, and completed in your project:All Meilisearch tasks are processed in batches. When the batch containing your task changes its status to succeeded, Meilisearch has finished processing your request.If the status changes to failed, Meilisearch was not able to fulfill your request. Check the object’s error field for more information.
If the task is still enqueued or processing, wait a few moments and query the database once again. You may also set up a webhook listener.When status changes to succeeded, Meilisearch has finished processing your request.If the task status changes to failed, Meilisearch was not able to fulfill your request. Check the task object’s error field for more information.
You can attach a customMetadata query parameter to document operations. This metadata string appears in task responses and webhook payloads, making it easier to track which batch of data triggered a specific task.
This is particularly useful when combined with webhooks, as the metadata lets you correlate incoming webhook notifications with specific data pipelines or scheduled imports.
You have seen what happens when an API request adds a task to the task queue, and how to check the status of that task. Consult the task API reference and the asynchronous operations explanation for more information on how tasks work.