# Tasks

The /tasks route gives information about the progress of asynchronous operations.

NOTE

The task uid is incremented globally.

# Get all tasks

GET
/tasks

List all tasks globally, regardless of index. The task objects are contained in the results array.

# Example

curl \
  -X GET 'http://localhost:7700/tasks'

# Response: 200 Ok

{
    "results": [
        {
            "uid": 1,
            "indexUid": "movies_reviews",
            "status": "enqueued",
            "type": "documentAddition",
            "duration": null,
            "enqueuedAt": "2021-08-12T10:00:00.000000Z",
            "startedAt": null,
            "finishedAt": null
        },
        {
            "uid": 0,
            "indexUid": "movies",
            "status": "succeeded",
            "type": "documentAddition",
            "details": { 
                    "receivedDocuments": 100,
                    "indexedDocuments": 100
            },
            "duration": "PT16S",
            "enqueuedAt": "2021-08-11T09:25:53.000000Z",
            "startedAt": "2021-08-11T10:03:00.000000Z",
            "finishedAt": "2021-08-11T10:03:16.000000Z"
        }
    ]
}

NOTE

Tasks are displayed in descending order by uid. This means that the most recently created task objects appear first.

# Get task

GET
/tasks/{task_uid}

Get a single task. The task uid is required.

# Example

curl \
  -X GET 'http://localhost:7700/tasks/1'

# Response: 200 Ok

Here is an example response representing a processed task.

{
    "uid": 1,
    "indexUid": "movies",
    "status": "succeeded",
    "type": "settingsUpdate",
    "details": {
        "rankingRules": [
            "typo",
            "ranking:desc",
            "words",
            "proximity",
            "attribute",
            "exactness"
        ]
    },
    "duration": "PT1S",
    "enqueuedAt": "2021-08-10T14:29:17.000000Z",
    "startedAt": "2021-08-10T14:29:18.000000Z",
    "finishedAt": "2021-08-10T14:29:19.000000Z"
}

# Get all tasks by index

GET
/indexes/{index_uid}/tasks

List all tasks for a given index. The index uid is required.

# Example

curl \
  -X GET 'http://localhost:7700/indexes/movies/tasks'

# Response: 200 Ok

{
    "results": [
        {
            "uid": 1,
            "indexUid": "movies",
            "status": "enqueued",
            "type": "documentAddition",
            "duration": null,
            "enqueuedAt": "2021-08-12T10:00:00.000000Z",
            "startedAt": null,
            "finishedAt": null
        },
        {
            "uid": 0,
            "indexUid": "movies",
            "status": "succeeded",
            "type": "documentAddition",
            "details": { 
                    "receivedDocuments": 100,
                    "indexedDocuments": 100
            },
            "duration": "PT16S",
            "enqueuedAt": "2021-08-11T09:25:53.000000Z",
            "startedAt": "2021-08-11T10:03:00.000000Z",
            "finishedAt": "2021-08-11T10:03:16.000000Z"
        }
    ]
}

# Get task by index

GET
/indexes/{index_uid}/tasks/{task_uid}

Get a single task in a given index. Both the index uid and task uid are required.

# Example

curl \
  -X GET 'http://localhost:7700/indexes/movies/tasks/1'

# Response: 200 Ok

Here is an example response representing a processed task.

{
    "uid": 1,
    "indexUid": "movies",
    "status": "succeeded",
    "type": "settingsUpdate",
    "details": {
        "rankingRules": [
            "typo",
            "ranking:desc",
            "words",
            "proximity",
            "attribute",
            "exactness"
        ]
    },
    "duration": "PT1S",
    "enqueuedAt": "2021-08-10T14:29:17.000000Z",
    "startedAt": "2021-08-10T14:29:18.000000Z",
    "finishedAt": "2021-08-10T14:29:19.000000Z"
}