Skip to content

Commit 45b5f82

Browse files
Merge #1746
1746: v0.28 tasks r=maryamsulemani97 a=dichotommy Changes related to the tasks API in v0.28. For a description of these changes, see the [associated issue](#1706). Co-authored-by: Tommy Melvin <[email protected]> Co-authored-by: Tommy <[email protected]>
2 parents 747c0a6 + f0a47f3 commit 45b5f82

23 files changed

+205
-192
lines changed

.code-samples.meilisearch.yaml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,24 @@ search_post_1: |-
7979
search_get_1: |-
8080
curl \
8181
-X GET 'http://localhost:7700/indexes/movies/search?q=american%20ninja'
82-
get_task_by_index_1: |-
83-
curl \
84-
-X GET 'http://localhost:7700/indexes/movies/tasks/1'
8582
get_all_tasks_1: |-
8683
curl \
8784
-X GET 'http://localhost:7700/tasks'
8885
get_task_1: |-
8986
curl \
9087
-X GET 'http://localhost:7700/tasks/1'
91-
get_all_tasks_by_index_1: |-
88+
get_all_tasks_filtering_1: |-
89+
curl \
90+
-X GET 'http://localhost:7700/tasks?indexUid=movies'
91+
get_all_tasks_filtering_2: |-
92+
curl \
93+
-X GET 'http://localhost:7700/tasks?status=succeeded,failed&type=documentAdditionOrUpdate'
94+
get_all_tasks_paginating_1: |-
95+
curl \
96+
-X GET 'http://localhost:7700/tasks?limit=2&from=10
97+
get_all_tasks_paginating_2: |-
9298
curl \
93-
-X GET 'http://localhost:7700/indexes/movies/tasks'
99+
-X GET 'http://localhost:7700/tasks?limit=2&from=8
94100
get_one_key_1: |-
95101
curl \
96102
-X GET 'http://localhost:7700/keys/d0552b41536279a0ad88bd595327b96f01176a60c2243e906c52ac02375f9bc4' \
@@ -529,7 +535,7 @@ getting_started_add_documents_md: |-
529535
```
530536
getting_started_check_task_status: |-
531537
curl \
532-
-X GET 'http://localhost:7700/indexes/movies/tasks/0'
538+
-X GET 'http://localhost:7700/tasks/0'
533539
getting_started_search_md: |-
534540
```bash
535541
curl \

.vuepress/public/sample-template.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ delete_all_documents_1: |-
1616
delete_one_document_1: |-
1717
delete_documents_1: |-
1818
search_post_1: |-
19-
get_task_by_index_1: |-
2019
get_all_tasks_1: |-
2120
get_task_1: |-
22-
get_all_tasks_by_index_1: |-
21+
get_all_tasks_filtering_1: |-
22+
get_all_tasks_filtering_2: |-
23+
get_all_tasks_paginating_1: |-
24+
get_all_tasks_paginating_2: |-
2325
get_one_key_1: |-
2426
get_all_keys_1: |-
2527
create_a_key_1: |-

learn/advanced/asynchronous_operations.md

Lines changed: 32 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ For example, updating the `filterableAttributes` index setting will require as m
1010

1111
Currently, these are Meilisearch's asynchronous operations:
1212

13-
- Updating index settings
14-
- Adding documents to an index
15-
- Updating documents in an index
1613
- Creating an index
1714
- Updating an index
1815
- Deleting an index
@@ -24,40 +21,40 @@ Currently, these are Meilisearch's asynchronous operations:
2421

2522
## Understanding tasks
2623

27-
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`.
24+
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.
2825

29-
### Response
26+
### Task API response
3027

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

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

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

4845
### Summarized task objects
4946

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

52-
| Field | Type | Description |
53-
|------------|---------|--------------------------------- |
54-
| `uid` | integer | Unique sequential identifier |
55-
| `indexUid` | string | Unique index identifier |
56-
| `status` | string | Status of the task. Value is `enqueued` |
57-
| `type` | string | Type of task |
58-
| `enqueuedAt` | string | Represents the date and time in the RFC 3339 format when the task has been `enqueued` |
49+
| Field | Type | Description |
50+
|--------------|---------|---------------------------------------------------------------------------------------|
51+
| `taskUid` | integer | Unique sequential identifier |
52+
| `indexUid` | string | Unique index identifier |
53+
| `status` | string | Status of the task. Value is `enqueued` |
54+
| `type` | string | Type of task |
55+
| `enqueuedAt` | string | Represents the date and time in the RFC 3339 format when the task has been `enqueued` |
5956

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

6259
### Task `status`
6360

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

7168
### Examples
7269

73-
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.
70+
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.
7471

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

7774
```json
7875
{
7976
"uid": 1,
8077
"indexUid": "movies",
8178
"status": "enqueued",
82-
"type": "documentAddition",
79+
"type": "documentAdditionOrUpdate",
8380
"details": {
8481
"receivedDocuments": 67493,
8582
"indexedDocuments": null
@@ -98,7 +95,7 @@ Later, you check the request's status one more time. It was successfully process
9895
"uid": 1,
9996
"indexUid": "movies",
10097
"status": "succeeded",
101-
"type": "documentAddition",
98+
"type": "documentAdditionOrUpdate",
10299
"details": {
103100
"receivedDocuments": 67493,
104101
"indexedDocuments": 67493
@@ -117,7 +114,7 @@ Had the task failed, the response would have included an `error` object:
117114
"uid": 1,
118115
"indexUid": "movies",
119116
"status": "failed",
120-
"type": "documentAddition",
117+
"type": "documentAdditionOrUpdate",
121118
"details": {
122119
"receivedDocuments": 67493,
123120
"indexedDocuments": 0
@@ -137,10 +134,10 @@ Had the task failed, the response would have included an `error` object:
137134

138135
## Task workflow
139136

140-
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)
137+
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)
141138
2. When your task reaches the front of the queue, Meilisearch begins working on it and changes the request `status` to `processing`
142139
3. Once the task has completed processing, Meilisearch marks it as `succeeded`, if it was successful, or `failed`, if there was an error.
143-
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)
140+
4. Tasks marked as `succeeded` or `failed` are not deleted and will remain visible in [the task list](/reference/api/tasks.md#get-tasks)
144141

145142
### Dumps
146143

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

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

159-
- `enqueued`: the task will remain enqueued and will be processed as usual once is restarted
160-
- `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`
156+
- `enqueued`: the task will remain enqueued and will be processed as usual once Meilisearch has been restarted
157+
- `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`
161158
- `succeeded`: there will be no data loss since the request was successfully completed
162159
- `failed`: the task failed and nothing has been altered in the database
163160

learn/advanced/updating.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ If it's something else, then you need to use the [reset displayed attributes end
138138

139139
<CodeSamples id="updating_guide_reset_displayed_attributes_new" />
140140

141-
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.
141+
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.
142142

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

learn/core_concepts/primary_key.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ The code below adds a document to the `books` index and sets `reference_number`
120120
"uid": 1,
121121
"indexUid": "books",
122122
"status": "succeeded",
123-
"type": "documentAddition",
123+
"type": "documentAdditionOrUpdate",
124124
"details":{
125125
"receivedDocuments":1,
126126
"indexedDocuments":1
@@ -177,7 +177,7 @@ This error occurs when you add documents for the first time and Meilisearch [fai
177177
"uid":1,
178178
"indexUid": "books",
179179
"status": "failed",
180-
"type": "documentAddition",
180+
"type": "documentAdditionOrUpdate",
181181
"details":{
182182
"receivedDocuments":5,
183183
"indexedDocuments":null
@@ -204,7 +204,7 @@ This error occurs when your index already has a primary key, but one of the docu
204204
"uid":1,
205205
"indexUid": "books",
206206
"status": "failed",
207-
"type": "documentAddition",
207+
"type": "documentAdditionOrUpdate",
208208
"details":{
209209
"receivedDocuments":1,
210210
"indexedDocuments":null
@@ -231,7 +231,7 @@ This happens when your document id does not have the correct [format](#formattin
231231
"uid":1,
232232
"indexUid": "books",
233233
"status": "failed",
234-
"type": "documentAddition",
234+
"type": "documentAdditionOrUpdate",
235235
"details":{
236236
"receivedDocuments":5,
237237
"indexedDocuments":null

learn/getting_started/quick_start.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,17 +188,17 @@ The previous command added documents from `movies.json` to a new index called `m
188188

189189
```json
190190
{
191-
"uid": 0,
191+
"taskUid": 0,
192192
"indexUid": "movies",
193193
"status": "enqueued",
194-
"type": "documentAddition",
194+
"type": "documentAdditionOrUpdate",
195195
"enqueuedAt": "2021-08-11T09:25:53.000000Z"
196196
}
197197
```
198198

199199
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**.
200200

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

203203
<CodeSamples id="getting_started_check_task_status" />
204204

@@ -209,7 +209,7 @@ If the document addition is successful, the response should look like this:
209209
"uid": 0,
210210
"indexUid": "movies",
211211
"status": "succeeded",
212-
"type": "documentAddition",
212+
"type": "documentAdditionOrUpdate",
213213
"details":{
214214
"receivedDocuments": 19547,
215215
"indexedDocuments": 19547

reference/api/displayed_attributes.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,15 @@ An array of strings that contains attributes of an index to display.
6262

6363
```json
6464
{
65-
"uid": 1,
65+
"taskUid": 1,
6666
"indexUid": "movies",
6767
"status": "enqueued",
6868
"type": "settingsUpdate",
6969
"enqueuedAt": "2021-08-11T09:25:53.000000Z"
7070
}
7171
```
7272

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

7575
## Reset displayed attributes
7676

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

9191
```json
9292
{
93-
"uid": 1,
93+
"taskUid": 1,
9494
"indexUid": "movies",
9595
"status": "enqueued",
9696
"type": "settingsUpdate",
9797
"enqueuedAt": "2021-08-11T09:25:53.000000Z"
9898
}
9999
```
100100

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

reference/api/distinct_attribute.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,15 @@ If the field does not exist, no error will be thrown.
5454

5555
```json
5656
{
57-
"uid": 1,
57+
"taskUid": 1,
5858
"indexUid": "movies",
5959
"status": "enqueued",
6060
"type": "settingsUpdate",
6161
"enqueuedAt": "2021-08-11T09:25:53.000000Z"
6262
}
6363
```
6464

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

6767
## Reset distinct attribute
6868

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

8181
```json
8282
{
83-
"uid": 1,
83+
"taskUid": 1,
8484
"indexUid": "movies",
8585
"status": "enqueued",
8686
"type": "settingsUpdate",
8787
"enqueuedAt": "2021-08-11T09:25:53.000000Z"
8888
}
8989
```
9090

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

0 commit comments

Comments
 (0)