# Distinct attribute
Child route of the settings route.
Distinct attribute is a field whose value will always be unique in the returned documents.
Distinct attribute can also be updated directly through the global settings route along with the other settings.
To learn more about distinct 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 distinct attribute
/indexes/{index_uid}/settings/distinct-attribute
Get the distinct attribute field of an index. The index uid
is required.
# Example
curl \
-X GET 'http://localhost:7700/indexes/shoes/settings/distinct-attribute'
# Response: 200 Ok
"skuid"
# Update distinct attribute
/indexes/{index_uid}/settings/distinct-attribute
Update the distinct attribute field of an 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, e.g., "distinctAttribute": "product.skuid"
.
# Body
A String: the field name.
More information about the body.
WARNING
If the field does not exist, no error will be thrown.
# Example
curl \
-X POST 'http://localhost:7700/indexes/shoes/settings/distinct-attribute' \
-H 'Content-Type: application/json' \
--data-binary '"skuid"'
# 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 distinct attribute
/indexes/{index_uid}/settings/distinct-attribute
Reset the distinct attribute field of an index to its default value. The index uid
is required.
Default value: null
# Example
curl \
-X DELETE 'http://localhost:7700/indexes/shoes/settings/distinct-attribute'
# 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.