# Sortable attributes

Child route of the settings route.

Sortable attributes can also be updated through the global settings route.

Attributes that can be used together with the sort search parameter. To learn more about sortable attributes, refer to our dedicated guide

WARNING

Updating the settings means overwriting the default settings of Meilisearch. You can reset to default values using the DELETE routes.

# Get sortable attributes

GET
/indexes/{index_uid}/settings/sortable-attributes

Get an index's sortableAttributes. The index uid is required.

# Example

curl \
  -X GET 'http://localhost:7700/indexes/books/settings/sortable-attributes'

# Response: 200 Ok

List the settings.

[
  "price", 
  "author.surname"
]

# Update sortable attributes

POST
/indexes/{index_uid}/settings/sortable-attributes

Update an index's sortable attributes list. This will re-index all documents in the index. This will re-index all documents in the index. The index uid is required.

If an attribute contains an object, you can use dot notation to set one or more of its keys as a value for this setting: "sortableAttributes": ["author.surname"].

You can read more about sorting at query time on our dedicated guide.

# Body

An array of strings containing the attributes that can be used to sort search results at query time.

You can read more about this setting at the feature reference page.

# Example

curl \
  -X POST 'http://localhost:7700/indexes/books/settings/sortable-attributes' \
  -H 'Content-Type: application/json' \
  --data-binary '[
    "price",
    "author"
  ]'

# Response: 202 Accepted

{
    "uid": 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.

# Reset sortable attributes

DELETE
/indexes/{index_uid}/settings/sortable-attributes

Reset an index's sortable attributes list back to its default value. The index uid is required.

# Default value

An empty array ([]).

# Example

curl \
  -X DELETE 'http://localhost:7700/indexes/books/settings/sortable-attributes'

# Response: 202 Accepted

{
    "uid": 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.