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.
NOTE
Updating the settings means overwriting the default settings of MeiliSearch. You can reset to default values using the DELETE
routes.
Learn more about distinct attribute.
Get distinct attribute
GET
/indexes/:index_uid/settings/distinct-attribute
Get the distinct attribute field of an index.
Path variables
Variable | Description |
---|---|
index_uid | The index UID |
Example
cURL
JavaScript
Python
PHP
Ruby
Go
Rust
curl \
-X GET 'http://localhost:7700/indexes/movies/settings/distinct-attribute'
client.index('movies').getDistinctAttribute()
client.index('movies').get_distinct_attribute()
$client->index('movies')->getDistinctAttribute();
client.index('movies').distinct_attribute
client.Index("movies").GetDistinctAttribute()
let distinct_attribute: Option<String> = movies.get_distinct_attribute().await.unwrap();
Response: 200 Ok
"movie_id"
Update distinct attribute
POST
/indexes/:index_uid/settings/distinct-attribute
Update the distinct attribute field of an index.
Path variables
Variable | Description |
---|---|
index_uid | The index UID |
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
JavaScript
Python
PHP
Ruby
Go
Rust
curl \
-X POST 'http://localhost:7700/indexes/movies/settings/distinct-attribute' \
--data '"movie_id"'
client.index('movies').updateDistinctAttribute('movie_id')
client.index('movies').update_distinct_attribute('movie_id')
$client->index('movies')->updateDistinctAttribute('movie_id');
client.index('movies').update_distinct_attribute('movie_id')
client.Index("movies").UpdateDistinctAttribute("movie_id")
let progress: Progress = movies.set_distinct_attribute("movie_id").await.unwrap();
Response: 202 Accepted
{
"updateId": 1
}
This updateId
allows you to track the current update.
Reset distinct attribute
DELETE
/indexes/:index_uid/settings/distinct-attribute
Reset the distinct attribute field of an index to its default value.
Default value: null
Path variables
Variable | Description |
---|---|
index_uid | The index UID |
Example
cURL
JavaScript
Python
PHP
Ruby
Go
Rust
curl \
-X DELETE 'http://localhost:7700/indexes/movies/settings/distinct-attribute'
client.index('movies').resetDistinctAttribute()
client.index('movies').reset_distinct_attribute()
$client->index('movies')->resetDistinctAttribute();
client.index('movies').reset_distinct_attribute
client.Index("movies").ResetDistinctAttribute()
let progress: Progress = movies.reset_distinct_attribute().await.unwrap();
Response: 202 Accepted
{
"updateId": 1
}
This updateId
allows you to track the current update.