Filterable attributes
Child route of the settings route.
Filterable attributes can also be updated through the global settings route.
Attributes that can be used as filters for filtering and faceted search. To learn more about filterable 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 filterable attributes
GET
/indexes/:index_uid/settings/filterable-attributes
Get an index’s filterableAttributes.
Path variables
Variable | Description |
---|---|
index_uid | The index UID |
Example
<>
cURL
JS
Python
PHP
Java
Ruby
Go
Rust
Swift
Dart
curl \
-X GET 'http://localhost:7700/indexes/movies/settings/filterable-attributes'
client.index('movies').getFilterableAttributes()
client.index('movies').get_filterable_attributes()
$client->index('movies')->getFilterableAttributes();
client.index("movies").getFilterableAttributes();
client.index('movies').filterable_attributes
client.Index("movies").GetFilterableAttributes()
let filterable_attributes: Vec<String> = movies.get_filterable_attributes().await.unwrap();
client.index("movies").getFilterableAttributes { (result: Result<[String], Swift.Error>) in
switch result {
case .success(let attributes):
print(attributes)
case .failure(let error):
print(error)
}
}
await client.index('movies').getFilterableAttributes();
Response: 200 Ok
List the settings.
[
"genres",
"director"
]
Update filterable attributes
POST
/indexes/:index_uid/settings/filterable-attributes
Update an index’s filterable attributes list. This will re-index all documents in the index.
Path variables
Variable | Description |
---|---|
index_uid | The index UID |
Body
An array of strings containing the attributes that can be used as filters at query time.
You can read more about this setting at the feature reference page.
Example
<>
cURL
JS
Python
PHP
Java
Ruby
Go
Rust
Swift
Dart
curl \
-X POST 'http://localhost:7700/indexes/movies/settings/filterable-attributes' \
-H 'Content-Type: application/json' \
--data-binary '[
"genres",
"director"
]'
client.index('movies')
.updateFilterableAttributes([
'genres',
'director'
])
client.index('movies').update_filterable_attributes([
'genres',
'director'
])
$client->index('movies')->updateFilterableAttributes([
'genres',
'director'
]);
Settings settings = new Settings();
settings.setFilterableAttributes(new String[] {"genres", "director"});
client.index("movies").updateSettings(settings);
client.index('movies').update_filterable_attributes([
'genres',
'director'
])
filterableAttributes := []string{
"genres",
"director",
}
client.Index("movies").UpdateFilterableAttributes(&filterableAttributes)
let filterable_attributes = [
"genres",
"director"
];
let progress: Progress = movies.set_filterable_attributes(&filterable_attributes).await.unwrap();
client.index("movies").updateFilterableAttributes(["genre", "director"]) { (result: Result<Update, Swift.Error>) in
switch result {
case .success(let update):
print(update)
case .failure(let error):
print(error)
}
}
await client.index('movies').updateFilterableAttributes([
'genres',
'director'
]);
Response: 202 Accepted
{ "updateId": 1 }
This updateId
allows you to track the current update.
Reset filterable attributes
DELETE
/indexes/:index_uid/settings/filterable-attributes
Reset an index’s filterable attributes list back to its default value.
Default value
An empty array ([]
).
Path variables
Variable | Description |
---|---|
index_uid | The index UID |
Example
<>
cURL
JS
Python
PHP
Java
Ruby
Go
Rust
Swift
Dart
curl \
-X DELETE 'http://localhost:7700/indexes/movies/settings/filterable-attributes'
client.index('movies').resetFilterableAttributes()
client.index('movies').reset_filterable_attributes()
$client->index('movies')->resetFilterableAttributes();
//Not yet implemented
client.index('movies').reset_filterable_attributes
client.Index("movies").ResetFilterableAttributes()
let progress: Progress = movies.reset_filterable_attributes().await.unwrap();
client.index("movies").resetFilterableAttributes { (result: Result<Update, Swift.Error>) in
switch result {
case .success(let attributes):
print(attributes)
case .failure(let error):
print(error)
}
}
await client.index('movies').resetFilterableAttributes();
Response: 202 Accepted
{ "updateId": 1 }
This updateId
allows you to track the current update.