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 .
WARNING
Updating the settings means overwriting the default settings of MeiliSearch. You can reset to default values using the DELETE
routes.
GET
Get the distinct attribute field of an index.
Path variables
<>
cURL
JS
Python
PHP
Java
Ruby
Go
Rust
Dart
curl \
-X GET 'http://localhost:7700/indexes/shoes/settings/distinct-attribute'
client.index('shoes').getDistinctAttribute()
client.index('shoes').get_distinct_attribute()
$client->index('shoes')->getDistinctAttribute();
client.index("shoes").getDistinctAttribute();
client.index('shoes').distinct_attribute
client.Index("shoes").GetDistinctAttribute()
let distinct_attribute: Option<String> = shoes.get_distinct_attribute().await.unwrap();
client.index("shoes").getDistinctAttribute { (result: Result<String, Swift.Error>) in
switch result {
print(distinctAttribute)
case .failure(let error):
print(error)
}
}
await client.index('shoes').getDistinctAttribute();
Response: 200 Ok
POST
Update the field of an index.
Path variables
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
JS
Python
PHP
Java
Ruby
Go
Rust
Dart
curl \
-X POST 'http://localhost:7700/indexes/shoes/settings/distinct-attribute' \
-H 'Content-Type: application/json' \
--data-binary '"skuid"'
client.index('shoes').updateDistinctAttribute('skuid')
client.index('shoes').update_distinct_attribute('skuid')
$client->index('shoes')->updateDistinctAttribute('skuid');
Settings settings = new Settings();
settings.setDistinctAttribute("skuid");
client.index("shoes").updateSettings(settings);
client.index('shoes').update_distinct_attribute('skuid')
client.Index("shoes").UpdateDistinctAttribute("skuid")
let progress: Progress = shoes.set_distinct_attribute("skuid").await.unwrap();
client.index("shoes").updateDistinctAttribute("skuid") { (result: Result<Update, Swift.Error>) in
switch result {
case .success(let update):
print(update)
print(error)
}
}
await client.index('shoes').updateDistinctAttribute('skuid');
Response:
{ "updateId": 1 }
This updateId
allows you to .
DELETE
Reset the distinct attribute field of an index to its default value.
Default value: null
Path variables
Example
<>
cURL
JS
Python
PHP
Java
Ruby
Go
Rust
Swift
Dart
curl \
-X DELETE 'http://localhost:7700/indexes/shoes/settings/distinct-attribute'
client.index('shoes').resetDistinctAttribute()
client.index('shoes').reset_distinct_attribute()
$client->index('shoes')->resetDistinctAttribute();
//Not yet implemented
client.index('shoes').reset_distinct_attribute
client.Index("shoes").ResetDistinctAttribute()
let progress: Progress = shoes.reset_distinct_attribute().await.unwrap();
client.index("shoes").resetDistinctAttribute { (result: Result<Update, Swift.Error>) in
switch result {
case .success(let update):
print(update)
case .failure(let error):
print(error)
}
}
await client.index('shoes').resetDistinctAttribute();