diff --git a/.code-samples.meilisearch.yaml b/.code-samples.meilisearch.yaml index 047cb60b9f..27a1758c4b 100644 --- a/.code-samples.meilisearch.yaml +++ b/.code-samples.meilisearch.yaml @@ -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' \ @@ -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 \ diff --git a/.vuepress/public/sample-template.yaml b/.vuepress/public/sample-template.yaml index 8b52eec657..5ff639bac0 100644 --- a/.vuepress/public/sample-template.yaml +++ b/.vuepress/public/sample-template.yaml @@ -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: |- diff --git a/learn/advanced/asynchronous_operations.md b/learn/advanced/asynchronous_operations.md index 1b2b32f056..c768b42760 100644 --- a/learn/advanced/asynchronous_operations.md +++ b/learn/advanced/asynchronous_operations.md @@ -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 @@ -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` @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/learn/advanced/updating.md b/learn/advanced/updating.md index 508f2a2969..ea1809bbe0 100644 --- a/learn/advanced/updating.md +++ b/learn/advanced/updating.md @@ -138,7 +138,7 @@ If it's something else, then you need to use the [reset displayed attributes end -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. diff --git a/learn/core_concepts/primary_key.md b/learn/core_concepts/primary_key.md index 08c6d1fd3a..4eab7f9abc 100644 --- a/learn/core_concepts/primary_key.md +++ b/learn/core_concepts/primary_key.md @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/learn/getting_started/quick_start.md b/learn/getting_started/quick_start.md index 5d5d0ced71..79526e9e12 100644 --- a/learn/getting_started/quick_start.md +++ b/learn/getting_started/quick_start.md @@ -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: @@ -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 diff --git a/reference/api/displayed_attributes.md b/reference/api/displayed_attributes.md index 99f1448be2..97761ae830 100644 --- a/reference/api/displayed_attributes.md +++ b/reference/api/displayed_attributes.md @@ -62,7 +62,7 @@ An array of strings that contains attributes of an index to display. ```json { - "uid": 1, + "taskUid": 1, "indexUid": "movies", "status": "enqueued", "type": "settingsUpdate", @@ -70,7 +70,7 @@ An array of strings that contains attributes of an index to display. } ``` -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 @@ -90,7 +90,7 @@ All attributes found in the documents added to the index. ```json { - "uid": 1, + "taskUid": 1, "indexUid": "movies", "status": "enqueued", "type": "settingsUpdate", @@ -98,4 +98,4 @@ All attributes found in the documents added to the index. } ``` -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). diff --git a/reference/api/distinct_attribute.md b/reference/api/distinct_attribute.md index f321ff31e2..5fc1983993 100644 --- a/reference/api/distinct_attribute.md +++ b/reference/api/distinct_attribute.md @@ -54,7 +54,7 @@ If the field does not exist, no error will be thrown. ```json { - "uid": 1, + "taskUid": 1, "indexUid": "movies", "status": "enqueued", "type": "settingsUpdate", @@ -62,7 +62,7 @@ If the field does not exist, no error will be thrown. } ``` -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 @@ -80,7 +80,7 @@ Reset the [distinct attribute](/learn/configuration/settings.md#distinct-attribu ```json { - "uid": 1, + "taskUid": 1, "indexUid": "movies", "status": "enqueued", "type": "settingsUpdate", @@ -88,4 +88,4 @@ Reset the [distinct attribute](/learn/configuration/settings.md#distinct-attribu } ``` -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). diff --git a/reference/api/documents.md b/reference/api/documents.md index a7123d51b5..67b263af2a 100644 --- a/reference/api/documents.md +++ b/reference/api/documents.md @@ -113,15 +113,15 @@ The body is composed of a **JSON array** of documents. ```json { - "uid": 1, + "taskUid": 1, "indexUid": "movies", "status": "enqueued", - "type": "documentAddition", + "type": "documentAdditionOrUpdate", "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). ## Add or update documents @@ -168,15 +168,15 @@ The documents are matched because they have the same [primary key](/learn/core_c ```json { - "uid": 1, + "taskUid": 1, "indexUid": "movies", "status": "enqueued", - "type": "documentAddition", + "type": "documentAdditionOrUpdate", "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). ## Delete all documents @@ -192,15 +192,15 @@ Delete all documents in the specified index. The index [`uid`](/learn/core_conce ```json { - "uid": 1, + "taskUid": 1, "indexUid": "movies", "status": "enqueued", - "type": "clearAll", + "type": "documentDeletion", "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). ## Delete one document @@ -216,7 +216,7 @@ Delete one document based on its unique id. Both the index [`uid`](/learn/core_c ```json { - "uid": 1, + "taskUid": 1, "indexUid": "movies", "status": "enqueued", "type": "documentDeletion", @@ -224,7 +224,7 @@ Delete one document based on its unique id. Both the index [`uid`](/learn/core_c } ``` -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). ## Delete documents by batch @@ -248,7 +248,7 @@ The body must be a **JSON Array** with the unique id's of the documents to delet ```json { - "uid": 1, + "taskUid": 1, "indexUid": "movies", "status": "enqueued", "type": "documentDeletion", @@ -256,4 +256,4 @@ The body must be a **JSON Array** with the unique id's of the documents to delet } ``` -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). diff --git a/reference/api/error_codes.md b/reference/api/error_codes.md index 0dcc2b22e9..e2bfc6bb8c 100644 --- a/reference/api/error_codes.md +++ b/reference/api/error_codes.md @@ -168,3 +168,11 @@ The requested task does not exist. Please ensure that you are using the correct ### `invalid_typo_tolerance_min_word_size_for_typos` The `minWordSizeForTypos` object is invalid. The value for both `oneTypo` and `twoTypos` should be between `0` and `255`, and `twoTypos` should be greater or equal to `oneTypo`. + +### `invalid_task_status` + +The requested task status is invalid. Please use one of [these four possible values](/learn/advanced/asynchronous_operations.md#task-status). + +### `invalid_task_type` + +The requested task type is invalid. Please use one of the values defined in our [asynchronous operations guide](/learn/advanced/asynchronous_operations.md#task-api-response). diff --git a/reference/api/filterable_attributes.md b/reference/api/filterable_attributes.md index d91d4ba5bb..8ee65a221f 100644 --- a/reference/api/filterable_attributes.md +++ b/reference/api/filterable_attributes.md @@ -54,7 +54,7 @@ An array of strings containing the attributes that can be used as filters at que ```json { - "uid": 1, + "taskUid": 1, "indexUid": "movies", "status": "enqueued", "type": "settingsUpdate", @@ -62,7 +62,7 @@ An array of strings containing the attributes that can be used as filters at que } ``` -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 filterable attributes @@ -82,7 +82,7 @@ An empty array (`[]`). ```json { - "uid": 1, + "taskUid": 1, "indexUid": "movies", "status": "enqueued", "type": "settingsUpdate", @@ -90,4 +90,4 @@ An empty array (`[]`). } ``` -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). diff --git a/reference/api/indexes.md b/reference/api/indexes.md index 4b108640d0..4e6bb3ef6f 100644 --- a/reference/api/indexes.md +++ b/reference/api/indexes.md @@ -100,7 +100,7 @@ Creating an index is an asynchronous task. [You can read more about asynchronous ```json { - "uid": 0, + "taskUid": 0, "indexUid": "movies", "status": "enqueued", "type": "indexCreation", @@ -108,7 +108,7 @@ Creating an index is an asynchronous task. [You can read more about asynchronous } ``` -You can use the response's `uid` to [track the status of your request](/reference/api/tasks.md#get-task). +You can use the response's `taskUid` to [track the status of your request](/reference/api/tasks.md#get-one-task). ## Update an index @@ -140,7 +140,7 @@ This is an asynchronous task. [You can read more about asynchronous operations i ```json { - "uid": 1, + "taskUid": 1, "indexUid": "movies", "status": "enqueued", "type": "indexUpdate", @@ -148,7 +148,7 @@ This is an asynchronous task. [You can read more about asynchronous operations i } ``` -You can use the response's `uid` to [track the status of your request](/reference/api/tasks.md#get-task). +You can use the response's `taskUid` to [track the status of your request](/reference/api/tasks.md#get-one-task). ## Delete an index @@ -166,7 +166,7 @@ This is an asynchronous task. [You can read more about asynchronous operations i ```json { - "uid": 1, + "taskUid": 1, "indexUid": "movies", "status": "enqueued", "type": "indexDeletion", @@ -174,4 +174,4 @@ This is an asynchronous task. [You can read more about asynchronous operations i } ``` -You can use the response's `uid` to [track the status of your request](/reference/api/tasks.md#get-task). +You can use the response's `taskUid` to [track the status of your request](/reference/api/tasks.md#get-one-task). diff --git a/reference/api/keys.md b/reference/api/keys.md index a6582e1f69..8716a20d18 100644 --- a/reference/api/keys.md +++ b/reference/api/keys.md @@ -170,7 +170,7 @@ A list of API actions permitted for the key. `["*"]` for all actions. | indexes.get | Provides access to the [get one index](/reference/api/indexes.md#get-one-index) and [list all indexes](/reference/api/indexes.md#list-all-indexes) endpoints. **Non-authorized `indexes` will be omitted from the response**. | | indexes.update | Provides access to the [update index](/reference/api/indexes.md#update-an-index) endpoint. | | indexes.delete | Provides access to the [delete index](/reference/api/indexes.md#delete-an-index) endpoint. | -| tasks.get | Provides access to the [get one task](/reference/api/tasks.md#get-task) and [get all tasks](/reference/api/tasks.md#get-all-tasks) endpoints. **Tasks from non-authorized `indexes` will be omitted from the response**. Also provides access to the [get one task by index](/reference/api/tasks.md#get-task-by-index) and [get all tasks by index](/reference/api/tasks.md#get-all-tasks-by-index) endpoints on authorized indexes. | +| tasks.get | Provides access to the [get one task](/reference/api/tasks.md#get-one-task) and [get tasks](/reference/api/tasks.md#get-tasks) endpoints. **Tasks from non-authorized `indexes` will be omitted from the response**. | | settings.get | Provides access to the [get settings](/reference/api/settings.md#get-settings) endpoint and equivalents for all subroutes on authorized indexes. | | settings.update | Provides access to the [update settings](/reference/api/settings.md#update-settings) and [reset settings](/reference/api/settings.md#reset-settings) endpoints and equivalents for all subroutes on authorized indexes. | | stats.get | Provides access to the [get stats of an index](/reference/api/stats.md#get-stats-of-an-index) endpoint and the [get stats of all indexes](/reference/api/stats.md#get-stats-of-all-indexes) endpoint. For the latter, **non-authorized `indexes` are omitted from the response**. | diff --git a/reference/api/overview.md b/reference/api/overview.md index 656d76a7d5..5b1d8b8f69 100644 --- a/reference/api/overview.md +++ b/reference/api/overview.md @@ -81,7 +81,7 @@ Meilisearch is an **asynchronous API**. This means that in response to most writ ```json { - "uid": 1, + "taskUid": 1, "indexUid": "movies", "status": "enqueued", "type": "indexUpdate", @@ -89,6 +89,6 @@ Meilisearch is an **asynchronous API**. This means that in response to most writ } ``` -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). See more information about [asynchronous operations](/learn/advanced/asynchronous_operations.md). diff --git a/reference/api/ranking_rules.md b/reference/api/ranking_rules.md index ae25f32d4d..1b2228ec16 100644 --- a/reference/api/ranking_rules.md +++ b/reference/api/ranking_rules.md @@ -68,7 +68,7 @@ To add your own ranking rule, you have to communicate an attribute followed by a ```json { - "uid": 1, + "taskUid": 1, "indexUid": "movies", "status": "enqueued", "type": "settingsUpdate", @@ -76,7 +76,7 @@ To add your own ranking rule, you have to communicate an attribute followed by a } ``` -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 ranking rules @@ -112,7 +112,7 @@ An array that contains the [built-in ranking rules](/learn/core_concepts/relevan ```json { - "uid": 1, + "taskUid": 1, "indexUid": "movies", "status": "enqueued", "type": "settingsUpdate", @@ -120,4 +120,4 @@ An array that contains the [built-in ranking rules](/learn/core_concepts/relevan } ``` -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). diff --git a/reference/api/searchable_attributes.md b/reference/api/searchable_attributes.md index 47e82d0d02..75a4613232 100644 --- a/reference/api/searchable_attributes.md +++ b/reference/api/searchable_attributes.md @@ -65,7 +65,7 @@ A match in title will make a document more relevant than another document with a ```json { - "uid": 1, + "taskUid": 1, "indexUid": "movies", "status": "enqueued", "type": "settingsUpdate", @@ -73,7 +73,7 @@ A match in title will make a document more relevant than another document with a } ``` -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 searchable attributes @@ -93,7 +93,7 @@ All attributes found in the documents added to the index. ```json { - "uid": 1, + "taskUid": 1, "indexUid": "movies", "status": "enqueued", "type": "settingsUpdate", @@ -101,4 +101,4 @@ All attributes found in the documents added to the index. } ``` -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). diff --git a/reference/api/settings.md b/reference/api/settings.md index 2d22e9b45b..512e608eb1 100644 --- a/reference/api/settings.md +++ b/reference/api/settings.md @@ -137,7 +137,7 @@ If the provided index does not exist, it will be created. ```json { - "uid": 1, + "taskUid": 1, "indexUid": "movies", "status": "enqueued", "type": "settingsUpdate", @@ -145,7 +145,7 @@ If the provided index does not exist, it will be created. } ``` -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 settings @@ -176,7 +176,7 @@ All settings will be reset to their default value. ```json { - "uid": 1, + "taskUid": 1, "indexUid": "movies", "status": "enqueued", "type": "settingsUpdate", @@ -184,4 +184,4 @@ All settings will be reset to their default value. } ``` -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). diff --git a/reference/api/sortable_attributes.md b/reference/api/sortable_attributes.md index 3c36dc3ddc..6a74d071eb 100644 --- a/reference/api/sortable_attributes.md +++ b/reference/api/sortable_attributes.md @@ -55,7 +55,7 @@ An array of strings containing the attributes that can be used to sort search re ```json { - "uid": 1, + "taskUid": 1, "indexUid": "movies", "status": "enqueued", "type": "settingsUpdate", @@ -63,7 +63,7 @@ An array of strings containing the attributes that can be used to sort search re } ``` -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 sortable attributes @@ -83,7 +83,7 @@ An empty array (`[]`). ```json { - "uid": 1, + "taskUid": 1, "indexUid": "movies", "status": "enqueued", "type": "settingsUpdate", @@ -91,4 +91,4 @@ An empty array (`[]`). } ``` -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). diff --git a/reference/api/stop_words.md b/reference/api/stop_words.md index d5bcd1b5f2..f551799fef 100644 --- a/reference/api/stop_words.md +++ b/reference/api/stop_words.md @@ -58,7 +58,7 @@ If a list of stop-words already exists it will be overwritten (_replaced_). ```json { - "uid": 1, + "taskUid": 1, "indexUid": "movies", "status": "enqueued", "type": "settingsUpdate", @@ -66,7 +66,7 @@ If a list of stop-words already exists it will be overwritten (_replaced_). } ``` -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 stop-words @@ -86,7 +86,7 @@ Empty array: `[]` ```json { - "uid": 1, + "taskUid": 1, "indexUid": "movies", "status": "enqueued", "type": "settingsUpdate", @@ -94,4 +94,4 @@ Empty array: `[]` } ``` -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). diff --git a/reference/api/synonyms.md b/reference/api/synonyms.md index f5cfb91136..64fa1728c6 100644 --- a/reference/api/synonyms.md +++ b/reference/api/synonyms.md @@ -60,7 +60,7 @@ An object that contains all synonyms and their associated words. ```json { - "uid": 1, + "taskUid": 1, "indexUid": "movies", "status": "enqueued", "type": "settingsUpdate", @@ -68,7 +68,7 @@ An object that contains all synonyms and their associated words. } ``` -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 synonyms @@ -88,7 +88,7 @@ Empty object : `{}` ```json { - "uid": 1, + "taskUid": 1, "indexUid": "movies", "status": "enqueued", "type": "settingsUpdate", @@ -96,4 +96,4 @@ Empty object : `{}` } ``` -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). diff --git a/reference/api/tasks.md b/reference/api/tasks.md index 71a550b649..eb1ebc1d1a 100644 --- a/reference/api/tasks.md +++ b/reference/api/tasks.md @@ -6,12 +6,26 @@ The `/tasks` route gives information about the progress of [asynchronous operati 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. +Tasks are always returned in descending order of `uid`. This means that by default, **the most recently created `task` objects appear first**. + +Task results are [paginated](#paginating-tasks) and can be [filtered](#filtering-tasks). + +#### Query parameters + +| Query Parameter | Description | Default Value | +|-----------------|----------------------------------------------------------------------|:------------------------------:| +| **limit** | number of tasks to return | 20 | +| **from** | `uid` of the first task returned | `uid` of the last created task | +| **status** | [filter tasks](#filtering-tasks) by their `status` | all statuses | +| **type** | [filter tasks](#filtering-tasks) by their `type` | all types | +| **indexUid** | [filter tasks](#filtering-tasks) by their `indexUid`. Case-sensitive | all indexes | + ### Example @@ -25,7 +39,7 @@ List all tasks globally, regardless of index. The `task` objects are contained i "uid": 1, "indexUid": "movies_reviews", "status": "enqueued", - "type": "documentAddition", + "type": "documentAdditionOrUpdate", "duration": null, "enqueuedAt": "2021-08-12T10:00:00.000000Z", "startedAt": null, @@ -35,7 +49,7 @@ List all tasks globally, regardless of index. The `task` objects are contained i "uid": 0, "indexUid": "movies", "status": "succeeded", - "type": "documentAddition", + "type": "documentAdditionOrUpdate", "details": { "receivedDocuments": 100, "indexedDocuments": 100 @@ -49,99 +63,85 @@ List all tasks globally, regardless of index. The `task` objects are contained i } ``` -:::note -Tasks are displayed in descending order by `uid`. This means that **the most recently created `task` objects appear first**. -::: +### Filtering tasks -## Get task +You can filter the task list by the value of the `status`, `type`, or `indexUid` fields. For example, the following command returns all tasks belonging to the index `movies`. Note that the `indexUid` is case-sensitive: - + -Get a single [task](/learn/advanced/asynchronous_operations.md). The task `uid` is required. +Use the ampersand character `&` to combine filters, equivalent to a logical `AND`. Use the comma character `,` to add multiple filter values for a single field. -### Example +For example, the following command would return all `documentAdditionOrUpdate` tasks that either `succeeded` or `failed`: - - -#### Response: `200 Ok` + -Here is an example response representing [a processed task](/learn/advanced/asynchronous_operations.md#understanding-tasks). +At this time, `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`. -```json -{ - "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" -} -``` +[Read more about the possible values of these fields in our asynchronous operations guide.](/learn/advanced/asynchronous_operations.md) -## Get all tasks by index +### Paginating tasks - +The task list is paginated, by default returning 20 tasks at a time. You can adjust the number of documents returned using the `limit` parameter, and control where the list begins using the `from` parameter. -List all [tasks](/learn/advanced/asynchronous_operations.md) for a given [index](/learn/core_concepts/indexes.md). The index [`uid`](/learn/core_concepts/indexes.md#index-uid) is required. +For each call to this endpoint, the response will include the `next` field: this value should be passed to `from` to view the next "page" of results. When the value of `next` is `null`, there are no more tasks to view. -### Example +This command returns tasks two at a time starting from task `uid` `10`. - + -#### Response: `200 Ok` +**Response:** ```json { - "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" - } - ] + "results": [ + { + "uid": 10, + "indexUid": "elements", + "status": "succeeded", + "type": "indexCreation", + "details": { + "primaryKey": null + }, + "duration": "PT0.006034S", + "enqueuedAt": "2022-06-20T13:41:42.446908Z", + "startedAt": "2022-06-20T13:41:42.447477Z", + "finishedAt": "2022-06-20T13:41:42.453511Z" + }, + { + "uid": 9, + "indexUid": "particles", + "status": "succeeded", + "type": "indexCreation", + "details": { + "primaryKey": null + }, + "duration": "PT0.007317S", + "enqueuedAt": "2022-06-20T13:41:31.841575Z", + "startedAt": "2022-06-20T13:41:31.842116Z", + "finishedAt": "2022-06-20T13:41:31.849433Z" + } + ], + "limit": 2, + "from": 10, + "next": 8 } ``` -## Get task by index +To view the next page of results, you would repeat the same query, replacing the value of `from` with the value of `next`: + + + +When the returned value of `next` is `null`, you have reached the final page of results. - +## Get one task -Get a single [task](/learn/advanced/asynchronous_operations.md) in a given [index](/learn/core_concepts/indexes.md). Both the index [`uid`](/learn/core_concepts/indexes.md#index-uid) and task [`uid`](/learn/advanced/asynchronous_operations.md#response) are required. + + +Get a single [task](/learn/advanced/asynchronous_operations.md). The task `uid` is required. ### Example - + #### Response: `200 Ok` diff --git a/reference/api/typo_tolerance.md b/reference/api/typo_tolerance.md index 4c686f6f84..e03a627339 100644 --- a/reference/api/typo_tolerance.md +++ b/reference/api/typo_tolerance.md @@ -107,7 +107,7 @@ An array of attributes for which the typo tolerance feature is disabled. ```json { - "uid": 1, + "taskUid": 1, "indexUid": "books", "status": "enqueued", "type": "settingsUpdate", @@ -115,7 +115,7 @@ An array of attributes for which the typo tolerance feature is disabled. } ``` -You can use the returned `uid` to get more details on [the status of the task](/reference/api/tasks.md#get-task). +You can use the returned `taskUid` to get more details on [the status of the task](/reference/api/tasks.md#get-one-task). ## Reset typo tolerance @@ -129,7 +129,7 @@ Reset an index's typo tolerance settings to their default value. The index [`uid ```json { - "uid": 1, + "taskUid": 1, "indexUid": "books", "status": "enqueued", "type": "settingsUpdate", @@ -137,4 +137,4 @@ Reset an index's typo tolerance settings to their default value. The index [`uid } ``` -You can use the returned `uid` to get more details on [the status of the task](/reference/api/tasks.md#get-task). +You can use the returned `taskUid` to get more details on [the status of the task](/reference/api/tasks.md#get-one-task). diff --git a/resources/faq.md b/resources/faq.md index dd22872afe..f683947224 100644 --- a/resources/faq.md +++ b/resources/faq.md @@ -51,19 +51,19 @@ More datasets and setting configurations are available [in this repository](http ## I did a call to an API route and got an object as a response. What does it mean? -All asynchronous operations return a summarized version of the [`task` object](/learn/advanced/asynchronous_operations.md#response). +All asynchronous operations return a [summarized version of the `task` object](/learn/advanced/asynchronous_operations.md#summarized-task-objects). ```json { - "uid": 1, + "taskUid": 1, "indexUid": "movies", "status": "enqueued", - "type": "documentAddition", + "type": "documentAdditionOrUpdate", "enqueuedAt": "2021-08-11T09:25:53.000000Z" } ``` -This response indicates that the operation has been taken into account and will be processed once it reaches the front of the queue. You can use this `uid` to get more details on [the status of the task](/reference/api/tasks.md#get-task). +This response indicates that the operation has been taken into account and will be processed once it reaches the front of the queue. You can use this `taskUid` to get more details on [the status of the task](/reference/api/tasks.md#get-one-task). ## I am trying to add my documents but I keep receiving a `400 - Bad Request` response. @@ -151,7 +151,7 @@ See more [information about the primary key](/learn/core_concepts/primary_key.md ## I have uploaded my documents, but I get no result when I search in my index. -Your document upload probably failed. To understand why, please check the status of the document addition task using the `uid`. If the task failed, the response should contain an `error` object. +Your document upload probably failed. To understand why, please check the status of the document addition task using the returned `taskUid`. If the task failed, the response should contain an `error` object. Here is an example of a failed task: @@ -160,7 +160,7 @@ Here is an example of a failed task: "uid": 1, "indexUid": "movies", "status": "failed", - "type": "documentAddition", + "type": "documentAdditionOrUpdate", "details": { "receivedDocuments": 67493, "indexedDocuments": 0