Configuring the number of returned tasks
By default, Meilisearch returns a list of 20 tasks for each request when you query the get tasks endpoint. This guide shows you how to navigate the task list using query parameters.
Paginating batches with the /batches route follows the same rules as paginating tasks.
Configuring the number of returned tasks
Use the limit parameter to change the number of returned tasks:
cURL
JS
Python
PHP
Java
Ruby
Go
C#
Rust
Swift
Dart
curl \
-X GET 'MEILISEARCH_URL/tasks?limit=2&from=10 \
-H 'Authorization: Bearer API_KEY'
client.tasks.getTasks({ limit: 2, from: 10 })
client.get_tasks({
'limit': 2,
'from': 10
})
$taskQuery = (new TasksQuery())->setLimit(2)->setFrom(10));
$client->getTasks($taskQuery);
TasksQuery query = new TasksQuery()
.setLimit(2)
.setFrom(10);
client.index("movies").getTasks(query);
client.tasks(limit: 2, from: 10)
client.GetTasks(&meilisearch.TasksQuery{
Limit: 2,
From: 10,
});
ResourceResults<TaskInfo> taskResult = await client.GetTasksAsync(new TasksQuery { Limit = 2, From = 10 });
let mut query = TasksSearchQuery::new(&client)
.with_limit(2)
.with_from(10)
.execute()
.await
.unwrap();
client.getTasks(params: TasksQuery(limit: 2, from: 10)) { result in
switch result {
case .success(let taskResult):
print(taskResult)
case .failure(let error):
print(error)
}
}
await client.getTasks(params: TasksQuery(limit: 2, from: 10));
Meilisearch will return a batch of tasks. Each batch of returned tasks is often called a “page” of tasks, and the size of that page is determined by limit:
{
"results": [
…
],
"total": 50,
"limit": 2,
"from": 10,
"next": 8
}
It is possible none of the returned tasks are the ones you are looking for. In that case, you will need to use the get all tasks request response to navigate the results.
Navigating the task list with from and next
Use the next value included in the response to your previous query together with from to fetch the next set of results:
cURL
JS
Python
PHP
Java
Ruby
Go
C#
Rust
Swift
Dart
curl \
-X GET 'MEILISEARCH_URL/tasks?limit=2&from=8 \
-H 'Authorization: Bearer API_KEY'
client.tasks.getTasks({ limit: 2, from: 8 })
client.get_tasks({
'limit': 2,
'from': 8
})
$taskQuery = (new TasksQuery())->setLimit(2)->setFrom(8));
$client->getTasks($taskQuery);
TasksQuery query = new TasksQuery()
.setLimit(2)
.setFrom(8);
client.index("movies").getTasks(query);
client.tasks(limit: 2, from: 8)
client.GetTasks(&meilisearch.TasksQuery{
Limit: 2,
From: 8,
});
ResourceResults<TaskInfo> taskResult = await client.GetTasksAsync(new TasksQuery { Limit = 2, From = 8 });
let mut query = TasksSearchQuery::new(&client)
.with_limit(2)
.from(8)
.execute()
.await
.unwrap();
client.getTasks(params: TasksQuery(limit: 2, from: 8)) { result in
switch result {
case .success(let taskResult):
print(taskResult)
case .failure(let error):
print(error)
}
}
await client.getTasks(params: TasksQuery(limit: 2, from: 8));
This will return a new batch of tasks:
{
"results": [
…
],
"total": 50,
"limit": 2,
"from": 8,
"next": 6
}
When the value of next is null, you have reached the final set of results.
Use from and limit together with task filtering parameters to navigate filtered task lists.
Deleting tasks from the database
Use the delete tasks endpoint to remove tasks from the database based on uid, status, type, indexUid, canceledBy, or date.
You can only delete finished tasks (succeeded, failed, or canceled). enqueued and processing tasks cannot be deleted: cancel them first using the cancel tasks endpoint.
Task deletion is an atomic transaction: either all matched tasks are successfully deleted, or none are.
Automatic task cleanup
Meilisearch stores up to 1 million tasks in the task database. If enqueuing a new task would exceed this limit, Meilisearch automatically attempts to delete the oldest 100,000 finished tasks to make room. If there are no finished tasks in the database, Meilisearch does not delete anything and enqueues the new task as usual. This automatic cleanup keeps the task database bounded without interrupting ongoing work.
Next steps
Filter tasks
Use query parameters to filter tasks by status, type, and more.
Monitor tasks
Check the status of asynchronous operations in real time.
Asynchronous operations
Understand how Meilisearch processes tasks in the background.
