Skip to content

Commit 1508511

Browse files
v1.16: Add sort parameter to /documents route (#3318)
1 parent 4d5f14e commit 1508511

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

reference/api/documents.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ Use `offset` and `limit` to browse through documents.
4848
| **`fields`** | Array of strings/`null` | `*` | Document attributes to show (case-sensitive, comma-separated) |
4949
| **`filter`** | String/Array of array of strings/`null` | N/A | Refine results based on attributes in the `filterableAttributes` list |
5050
| **`retrieveVectors`** | Boolean | `false` | Return document vector data with search result |
51+
| **`sort`** | `null` | A list of attributes written as an array or as a comma-separated string |
52+
5153
| **`ids`** | Array of primary keys | `null` | Return documents based on their primary keys |
5254

5355
<Note>
@@ -137,6 +139,7 @@ Using the query parameters `offset` and `limit`, you can browse through all your
137139
| **`fields`** | `*` | Document attributes to show (case-sensitive, comma-separated) |
138140
| **`filter`** | N/A | Refine results based on attributes in the `filterableAttributes` list |
139141
| **`retrieveVectors`** | `false` | Return document vector data with search result |
142+
| **`sort`** | `null` | A list of comma-separated attributes |
140143
| **`ids`** | `null` | Return documents based on their primary keys |
141144

142145
### Response

reference/errors/error_codes.mdx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,14 @@ The [`limit`](/reference/api/documents#query-parameters) parameter is invalid. I
180180

181181
The [`offset`](/reference/api/documents#query-parameters) parameter is invalid. It should be an integer.
182182

183+
## `invalid_document_sort`
184+
185+
This error occurs if:
186+
187+
- The syntax for the [`sort`](/reference/api/documents#body) parameter is invalid
188+
- The attribute used for sorting is not defined in the [`sortableAttributes`](/reference/api/settings#sortable-attributes) list or the `sort` ranking rule is missing from the settings
189+
- A reserved keyword like `_geo`, `_geoDistance`, `_geoRadius`, or `_geoBoundingBox` is used as a filter
190+
183191
## `invalid_document_geo_field`
184192

185193
The provided `_geo` field of one or more documents is invalid. Meilisearch expects `_geo` to be an object with two fields, `lat` and `lng`, each containing geographic coordinates expressed as a string or floating point number. Read more about `_geo` and how to troubleshoot it in [our dedicated guide](/learn/filtering_and_sorting/geosearch).

0 commit comments

Comments
 (0)