Go to homev1.4 Docs

    Managing the task database

    Filtering tasks

    Querying the get tasks endpoint returns all tasks that have not been deleted. Use query parameters to filter tasks based on uid, status, type, indexUid, canceledBy, or date. Separate multiple values with a comma (,).

    Filter by uid

    The following code sample returns tasks with uids 5, 10, and 13:

    curl \
      -X GET 'http://localhost:7700/tasks?uids=5,10,13'

    Filter by status

    The following code sample returns tasks with the failed and canceled statuses:

    curl \
      -X GET 'http://localhost:7700/tasks?statuses=failed,canceled'

    Filter by type

    The following code sample returns dumpCreation and indexSwap tasks:

    curl \
      -X GET 'http://localhost:7700/tasks?types=dumpCreation,indexSwap'

    Filter by indexUid

    The following command returns all tasks belonging to the index movies. Note that the indexUid is case-sensitive:

    curl \
      -X GET 'http://localhost:7700/tasks?indexUids=movies'

    Filter by canceledBy

    Use the canceledBy filter to view all tasks canceled by one or more taskCancelation tasks:

    curl \
      -X GET 'http://localhost:7700/tasks?canceledBy=9,15'

    Filter by date

    You can filter tasks by their enqueuedAt, startedAt, and finishedAt fields. To do so, prepend either before or after to each field name:

    This filter accepts dates formatted according to RFC 3339:

    curl \
      -X GET 'http://localhost:7700/tasks?afterEnqueuedAt=2020-10-11T11:49:53.000Z'

    The above code sample will return all tasks enqueued after 11:49:53:00 on 11 Oct 2020.

    NOTE

    Date filters are equivalent to < or > operations and do not include the specified value. It is not possible to perform or operations with a task date filter.

    Combine filters

    You can combine task filters. Use the ampersand character (&) to combine filters, equivalent to a logical AND.

    The following code sample returns all tasks in the movies index that have the type documentAdditionOrUpdate or documentDeletion and have the status of processing.

    curl \
      -X GET 'http://localhost:7700/tasks?indexUids=movies&types=documentAdditionOrUpdate,documentDeletion&statuses=processing'

    OR operations between different filters are not supported. For example, you cannot view only tasks which have a type of documentAddition or a status of failed.

    Paginating tasks

    By default, Meilisearch returns a list of 20 tasks for each request. You can adjust the number of tasks returned using the limit parameter, and control where the list begins using the from parameter.

    For each call to this endpoint, the response will include the next field. When you call the endpoint again, pass this value as the from parameter to view the next set of results.

    The following command returns two tasks at a time, starting from task uid 10:

    curl \
      -X GET 'http://localhost:7700/tasks?limit=2&from=10

    Response:

    {
      "results": [],
      "total": 50,
      "limit": 2,
      "from": 10,
      "next": 8
    }
    

    To view the next set of results, you would repeat the same query, replacing the value of from with the value of next:

    curl \
      -X GET 'http://localhost:7700/tasks?limit=2&from=8

    When the returned value of next is null, you have reached the final set of results.