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

  1. /indexes/:index_uid/settings/filterable-attributes

Get an index’s filterableAttributes.

Path variables

VariableDescription
index_uidThe index UID

Example

<>

cURL

JS

Python

PHP

Java

Ruby

Go

Rust

Swift

Dart

  1. curl \
  2. -X GET 'http://localhost:7700/indexes/movies/settings/filterable-attributes'
  1. client.index('movies').getFilterableAttributes()
  1. client.index('movies').get_filterable_attributes()
  1. $client->index('movies')->getFilterableAttributes();
  1. client.index("movies").getFilterableAttributes();
  1. client.index('movies').filterable_attributes
  1. client.Index("movies").GetFilterableAttributes()
  1. let filterable_attributes: Vec<String> = movies.get_filterable_attributes().await.unwrap();
  1. client.index("movies").getFilterableAttributes { (result: Result<[String], Swift.Error>) in
  2. switch result {
  3. case .success(let attributes):
  4. print(attributes)
  5. case .failure(let error):
  6. print(error)
  7. }
  8. }
  1. await client.index('movies').getFilterableAttributes();

Response: 200 Ok

List the settings.

  1. [
  2. "genres",
  3. "director"
  4. ]

Update filterable attributes

POST

  1. /indexes/:index_uid/settings/filterable-attributes

Update an index’s filterable attributes list. This will re-index all documents in the index.

Path variables

VariableDescription
index_uidThe 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

  1. curl \
  2. -X POST 'http://localhost:7700/indexes/movies/settings/filterable-attributes' \
  3. -H 'Content-Type: application/json' \
  4. --data-binary '[
  5. "genres",
  6. "director"
  7. ]'
  1. client.index('movies')
  2. .updateFilterableAttributes([
  3. 'genres',
  4. 'director'
  5. ])
  1. client.index('movies').update_filterable_attributes([
  2. 'genres',
  3. 'director'
  4. ])
  1. $client->index('movies')->updateFilterableAttributes([
  2. 'genres',
  3. 'director'
  4. ]);
  1. Settings settings = new Settings();
  2. settings.setFilterableAttributes(new String[] {"genres", "director"});
  3. client.index("movies").updateSettings(settings);
  1. client.index('movies').update_filterable_attributes([
  2. 'genres',
  3. 'director'
  4. ])
  1. filterableAttributes := []string{
  2. "genres",
  3. "director",
  4. }
  5. client.Index("movies").UpdateFilterableAttributes(&filterableAttributes)
  1. let filterable_attributes = [
  2. "genres",
  3. "director"
  4. ];
  5. let progress: Progress = movies.set_filterable_attributes(&filterable_attributes).await.unwrap();
  1. client.index("movies").updateFilterableAttributes(["genre", "director"]) { (result: Result<Update, Swift.Error>) in
  2. switch result {
  3. case .success(let update):
  4. print(update)
  5. case .failure(let error):
  6. print(error)
  7. }
  8. }
  1. await client.index('movies').updateFilterableAttributes([
  2. 'genres',
  3. 'director'
  4. ]);

Response: 202 Accepted

  1. { "updateId": 1 }

This updateId allows you to track the current update.

Reset filterable attributes

DELETE

  1. /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

VariableDescription
index_uidThe index UID

Example

<>

cURL

JS

Python

PHP

Java

Ruby

Go

Rust

Swift

Dart

  1. curl \
  2. -X DELETE 'http://localhost:7700/indexes/movies/settings/filterable-attributes'
  1. client.index('movies').resetFilterableAttributes()
  1. client.index('movies').reset_filterable_attributes()
  1. $client->index('movies')->resetFilterableAttributes();
  1. //Not yet implemented
  1. client.index('movies').reset_filterable_attributes
  1. client.Index("movies").ResetFilterableAttributes()
  1. let progress: Progress = movies.reset_filterable_attributes().await.unwrap();
  1. client.index("movies").resetFilterableAttributes { (result: Result<Update, Swift.Error>) in
  2. switch result {
  3. case .success(let attributes):
  4. print(attributes)
  5. case .failure(let error):
  6. print(error)
  7. }
  8. }
  1. await client.index('movies').resetFilterableAttributes();

Response: 202 Accepted

  1. { "updateId": 1 }

This updateId allows you to track the current update.