Skip to content

v0.28 tasks #1746

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Jun 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,24 @@ search_post_1: |-
search_get_1: |-
curl \
-X GET 'http://localhost:7700/indexes/movies/search?q=american%20ninja'
get_task_by_index_1: |-
curl \
-X GET 'http://localhost:7700/indexes/movies/tasks/1'
get_all_tasks_1: |-
curl \
-X GET 'http://localhost:7700/tasks'
get_task_1: |-
curl \
-X GET 'http://localhost:7700/tasks/1'
get_all_tasks_by_index_1: |-
get_all_tasks_filtering_1: |-
curl \
-X GET 'http://localhost:7700/tasks?indexUid=movies'
get_all_tasks_filtering_2: |-
curl \
-X GET 'http://localhost:7700/tasks?status=succeeded,failed&type=documentAdditionOrUpdate'
get_all_tasks_paginating_1: |-
curl \
-X GET 'http://localhost:7700/tasks?limit=2&from=10
get_all_tasks_paginating_2: |-
curl \
-X GET 'http://localhost:7700/indexes/movies/tasks'
-X GET 'http://localhost:7700/tasks?limit=2&from=8
get_one_key_1: |-
curl \
-X GET 'http://localhost:7700/keys/d0552b41536279a0ad88bd595327b96f01176a60c2243e906c52ac02375f9bc4' \
Expand Down Expand Up @@ -529,7 +535,7 @@ getting_started_add_documents_md: |-
```
getting_started_check_task_status: |-
curl \
-X GET 'http://localhost:7700/indexes/movies/tasks/0'
-X GET 'http://localhost:7700/tasks/0'
getting_started_search_md: |-
```bash
curl \
Expand Down
6 changes: 4 additions & 2 deletions .vuepress/public/sample-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ delete_all_documents_1: |-
delete_one_document_1: |-
delete_documents_1: |-
search_post_1: |-
get_task_by_index_1: |-
get_all_tasks_1: |-
get_task_1: |-
get_all_tasks_by_index_1: |-
get_all_tasks_filtering_1: |-
get_all_tasks_filtering_2: |-
get_all_tasks_paginating_1: |-
get_all_tasks_paginating_2: |-
get_one_key_1: |-
get_all_keys_1: |-
create_a_key_1: |-
Expand Down
67 changes: 32 additions & 35 deletions learn/advanced/asynchronous_operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ For example, updating the `filterableAttributes` index setting will require as m

Currently, these are Meilisearch's asynchronous operations:

- Updating index settings
- Adding documents to an index
- Updating documents in an index
- Creating an index
- Updating an index
- Deleting an index
Expand All @@ -24,40 +21,40 @@ Currently, these are Meilisearch's asynchronous operations:

## Understanding tasks

Most of Meilisearch's asynchronous operations belong to a category called "tasks". After you have requested an asynchronous operation, you can use the [task API](/reference/api/tasks.md) to find the detailed status of your request. To do so, you will need your task's `uid`.
All of Meilisearch's asynchronous operations belong to a category called "tasks". After you have requested an asynchronous operation, you can use the [task API](/reference/api/tasks.md) to find the detailed status of your request. To do so, you will need the task's unique identifier.

### Response
### Task API response

The response from the [task API](/reference/api/tasks.md) will always include the following fields in the stated order:

| Field | Type | Description |
|--------------|---------|--------------------------------------------------------------------------------------------------------------------------------------------|
| `uid` | integer | The unique sequential identifier of the task |
| `indexUid` | string | The unique index identifier |
| `status` | string | The status of the task. Possible values are `enqueued`, `processing`, `succeeded`, `failed` |
| `type` | string | The type of task. Possible values are `indexCreation`, `indexUpdate`, `indexDeletion`, `documentAddition`, `documentPartial`, `documentDeletion`, `settingsUpdate`, `clearAll` |
| `details` | object | Detailed information on the task payload |
| `error` | object | Error details and context. Only present when a task has the `failed` status |
| `duration` | string | The total elapsed time the task spent in the `processing` state, in ISO 8601 format |
| `enqueuedAt` | string | The date and time when the task was first `enqueued`, in RFC 3339 format |
| `startedAt` | string | The date and time when the task began `processing`, in RFC 3339 format |
| `finishedAt` | string | The date and time when the task finished processing, whether `failed` or `succeeded`, in RFC 3339 format. |
| Field | Type | Description |
|--------------|---------|----------------------------------------------------------------------------------------------|
| `uid` | integer | The unique sequential identifier of the task |
| `indexUid` | string | The unique index identifier |
| `status` | string | The status of the task. Possible values are `enqueued`, `processing`, `succeeded`, `failed` |
| `type` | string | The type of task. Possible values are `indexCreation`, `indexUpdate`, `indexDeletion`, `documentAdditionOrUpdate`, `documentDeletion`, `settingsUpdate` |
| `details` | object | Detailed information on the task payload |
| `error` | object | Error details and context. Only present when a task has the `failed` status |
| `duration` | string | The total elapsed time the task spent in the `processing` state, in ISO 8601 format |
| `enqueuedAt` | string | The date and time when the task was first `enqueued`, in RFC 3339 format |
| `startedAt` | string | The date and time when the task began `processing`, in RFC 3339 format |
| `finishedAt` | string | The date and time when the task finished processing, whether `failed` or `succeeded`, in RFC 3339 format. |

If a task fails due to an error, all error fields will be appended to the task response in an `error` object.

### Summarized task objects

All asynchronous operations return a summarized version of the [`task` object](#response). It contains the following fields in the stated order:
All asynchronous operations return a summarized version of [the full `task` object](#task-api-response). It contains the following fields in the stated order:

| Field | Type | Description |
|------------|---------|--------------------------------- |
| `uid` | integer | Unique sequential identifier |
| `indexUid` | string | Unique index identifier |
| `status` | string | Status of the task. Value is `enqueued` |
| `type` | string | Type of task |
| `enqueuedAt` | string | Represents the date and time in the RFC 3339 format when the task has been `enqueued` |
| Field | Type | Description |
|--------------|---------|---------------------------------------------------------------------------------------|
| `taskUid` | integer | Unique sequential identifier |
| `indexUid` | string | Unique index identifier |
| `status` | string | Status of the task. Value is `enqueued` |
| `type` | string | Type of task |
| `enqueuedAt` | string | Represents the date and time in the RFC 3339 format when the task has been `enqueued` |

You can use this `uid` to get more details on [the status of the task](/reference/api/tasks.md#get-task).
You can use this `taskUid` to get more details on [the status of the task](/reference/api/tasks.md#get-one-task).

### Task `status`

Expand All @@ -70,16 +67,16 @@ Task responses always contain a field indicating the request's current `status`.

### Examples

Suppose you add a new document to your instance using the [add documents endpoint](/reference/api/documents.md#add-or-replace-documents) and receive a `uid` in response.
Suppose you add a new document to your instance using the [add documents endpoint](/reference/api/documents.md#add-or-replace-documents) and receive a `taskUid` in response.

When you query the task endpoint using this `uid`, you see that it has been enqueued:
When you query the [get task endpoint](/reference/api/tasks.md#get-one-task) using this value, you see that it has been enqueued:

```json
{
"uid": 1,
"indexUid": "movies",
"status": "enqueued",
"type": "documentAddition",
"type": "documentAdditionOrUpdate",
"details": {
"receivedDocuments": 67493,
"indexedDocuments": null
Expand All @@ -98,7 +95,7 @@ Later, you check the request's status one more time. It was successfully process
"uid": 1,
"indexUid": "movies",
"status": "succeeded",
"type": "documentAddition",
"type": "documentAdditionOrUpdate",
"details": {
"receivedDocuments": 67493,
"indexedDocuments": 67493
Expand All @@ -117,7 +114,7 @@ Had the task failed, the response would have included an `error` object:
"uid": 1,
"indexUid": "movies",
"status": "failed",
"type": "documentAddition",
"type": "documentAdditionOrUpdate",
"details": {
"receivedDocuments": 67493,
"indexedDocuments": 0
Expand All @@ -137,10 +134,10 @@ Had the task failed, the response would have included an `error` object:

## Task workflow

1. When you make a task request, Meilisearch puts it in the task queue, sets the task's `status` to `enqueued` and returns a [`task` object](/learn/advanced/asynchronous_operations.md#response)
1. When you make an [asynchronous request](#which-operations-are-async), Meilisearch puts it in the task queue, sets the task's `status` to `enqueued` and returns a [summarized `task` object](/learn/advanced/asynchronous_operations.md#summarized-task-objects)
2. When your task reaches the front of the queue, Meilisearch begins working on it and changes the request `status` to `processing`
3. Once the task has completed processing, Meilisearch marks it as `succeeded`, if it was successful, or `failed`, if there was an error.
4. Tasks marked as `succeeded` or `failed` are not deleted and will remain visible in [the task list](/reference/api/tasks.md#get-all-tasks)
4. Tasks marked as `succeeded` or `failed` are not deleted and will remain visible in [the task list](/reference/api/tasks.md#get-tasks)

### Dumps

Expand All @@ -156,8 +153,8 @@ Meilisearch's asynchronous tasks are atomic. This means that all operations conc

What happens to an asynchronous operation when Meilisearch is terminated changes depending on the request's `status`:

- `enqueued`: the task will remain enqueued and will be processed as usual once is restarted
- `processing`: there will be no consequences, since no part of the task has been committed to the database. After restarting, will treat the task as `enqueued`
- `enqueued`: the task will remain enqueued and will be processed as usual once Meilisearch has been restarted
- `processing`: there will be no consequences, since no part of the task has been committed to the database. After restarting, the task will be treated as `enqueued`
- `succeeded`: there will be no data loss since the request was successfully completed
- `failed`: the task failed and nothing has been altered in the database

Expand Down
2 changes: 1 addition & 1 deletion learn/advanced/updating.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ If it's something else, then you need to use the [reset displayed attributes end

<CodeSamples id="updating_guide_reset_displayed_attributes_new" />

This command returns a `uid`. You can use this to [track the status of the operation](/reference/api/tasks.md#get-task). Once the status is `succeeded`, you're good to go.
This command returns a `taskUid`. You can use this to [track the status of the operation](/reference/api/tasks.md#get-one-task). Once the status is `succeeded`, you're good to go.

Now that all fields are displayed, proceed to the next step.

Expand Down
8 changes: 4 additions & 4 deletions learn/core_concepts/primary_key.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ The code below adds a document to the `books` index and sets `reference_number`
"uid": 1,
"indexUid": "books",
"status": "succeeded",
"type": "documentAddition",
"type": "documentAdditionOrUpdate",
"details":{
"receivedDocuments":1,
"indexedDocuments":1
Expand Down Expand Up @@ -177,7 +177,7 @@ This error occurs when you add documents for the first time and Meilisearch [fai
"uid":1,
"indexUid": "books",
"status": "failed",
"type": "documentAddition",
"type": "documentAdditionOrUpdate",
"details":{
"receivedDocuments":5,
"indexedDocuments":null
Expand All @@ -204,7 +204,7 @@ This error occurs when your index already has a primary key, but one of the docu
"uid":1,
"indexUid": "books",
"status": "failed",
"type": "documentAddition",
"type": "documentAdditionOrUpdate",
"details":{
"receivedDocuments":1,
"indexedDocuments":null
Expand All @@ -231,7 +231,7 @@ This happens when your document id does not have the correct [format](#formattin
"uid":1,
"indexUid": "books",
"status": "failed",
"type": "documentAddition",
"type": "documentAdditionOrUpdate",
"details":{
"receivedDocuments":5,
"indexedDocuments":null
Expand Down
8 changes: 4 additions & 4 deletions learn/getting_started/quick_start.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,17 +188,17 @@ The previous command added documents from `movies.json` to a new index called `m

```json
{
"uid": 0,
"taskUid": 0,
"indexUid": "movies",
"status": "enqueued",
"type": "documentAddition",
"type": "documentAdditionOrUpdate",
"enqueuedAt": "2021-08-11T09:25:53.000000Z"
}
```

Most database operations in Meilisearch are [asynchronous](/learn/advanced/asynchronous_operations.md). This means that rather than being processed instantly, **API requests are added to a queue and processed one at a time**.

Use the returned `uid` to [check the status](/reference/api/tasks.md) of your documents:
Use the returned `taskUid` to [check the status](/reference/api/tasks.md) of your documents:

<CodeSamples id="getting_started_check_task_status" />

Expand All @@ -209,7 +209,7 @@ If the document addition is successful, the response should look like this:
"uid": 0,
"indexUid": "movies",
"status": "succeeded",
"type": "documentAddition",
"type": "documentAdditionOrUpdate",
"details":{
"receivedDocuments": 19547,
"indexedDocuments": 19547
Expand Down
8 changes: 4 additions & 4 deletions reference/api/displayed_attributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ An array of strings that contains attributes of an index to display.

```json
{
"uid": 1,
"taskUid": 1,
"indexUid": "movies",
"status": "enqueued",
"type": "settingsUpdate",
"enqueuedAt": "2021-08-11T09:25:53.000000Z"
}
```

You can use this `uid` to get more details on [the status of the task](/reference/api/tasks.md#get-task).
You can use this `taskUid` to get more details on [the status of the task](/reference/api/tasks.md#get-one-task).

## Reset displayed attributes

Expand All @@ -90,12 +90,12 @@ All attributes found in the documents added to the index.

```json
{
"uid": 1,
"taskUid": 1,
"indexUid": "movies",
"status": "enqueued",
"type": "settingsUpdate",
"enqueuedAt": "2021-08-11T09:25:53.000000Z"
}
```

You can use this `uid` to get more details on [the status of the task](/reference/api/tasks.md#get-task).
You can use this `taskUid` to get more details on [the status of the task](/reference/api/tasks.md#get-one-task).
8 changes: 4 additions & 4 deletions reference/api/distinct_attribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ If the field does not exist, no error will be thrown.

```json
{
"uid": 1,
"taskUid": 1,
"indexUid": "movies",
"status": "enqueued",
"type": "settingsUpdate",
"enqueuedAt": "2021-08-11T09:25:53.000000Z"
}
```

You can use this `uid` to get more details on [the status of the task](/reference/api/tasks.md#get-task).
You can use this `taskUid` to get more details on [the status of the task](/reference/api/tasks.md#get-one-task).

## Reset distinct attribute

Expand All @@ -80,12 +80,12 @@ Reset the [distinct attribute](/learn/configuration/settings.md#distinct-attribu

```json
{
"uid": 1,
"taskUid": 1,
"indexUid": "movies",
"status": "enqueued",
"type": "settingsUpdate",
"enqueuedAt": "2021-08-11T09:25:53.000000Z"
}
```

You can use this `uid` to get more details on [the status of the task](/reference/api/tasks.md#get-task).
You can use this `taskUid` to get more details on [the status of the task](/reference/api/tasks.md#get-one-task).
Loading