Filterable attributes

Child route of the settings route.

Attributes that can be used as filters for filtering and faceted search. You can learn more about filtering and faceted search in our dedicated guide.

Filterable attributes can also be updated through the global settings route.

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

JavaScript

Python

PHP

Ruby

Go

Rust

  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').filterable_attributes
  1. client.Index("movies").GetFilterableAttributes()
  1. let filterable_attributes: Vec<String> = movies.get_filterable_attributes().await.unwrap();

Response: 200 Ok

List the settings.

  1. ["genres", "director"]

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

JavaScript

Python

PHP

Ruby

Go

Rust

  1. curl \
  2. -X POST 'http://localhost:7700/indexes/movies/settings/filterable-attributes' \
  3. --data '[
  4. "genres",
  5. "director"
  6. ]'
  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. 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();

Response: 202 Accepted

  1. {
  2. "updateId": 1
  3. }

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

JavaScript

Python

PHP

Ruby

Go

Rust

  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. client.index('movies').reset_filterable_attributes
  1. client.Index("movies").ResetFilterableAttributes()
  1. let progress: Progress = movies.reset_filterable_attributes().await.unwrap();

Response: 202 Accepted

  1. {
  2. "updateId": 1
  3. }

This updateId allows you to track the current update.