Displayed attributes

Child route of the settings route.

The fields whose attributes are added to the displayed-attributes list are displayed in each matching document.
By default, all fields are considered to be displayedAttributes. This behavior is represented by the * in the settings. Setting displayedAttributes to an empty array [] will reset the setting to its default value.

Displayed attributes 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 displayed fields.

Get displayed attributes

GET

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

Get the displayed attributes of an index.

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/displayed-attributes'
  1. client.index('movies').getDisplayedAttributes()
  1. client.index('movies').get_displayed_attributes()
  1. $client->index('movies')->getDisplayedAttributes();
  1. client.index('movies').get_displayed_attributes
  1. client.Index("movies").GetDisplayedAttributes()
  1. let displayed_attributes: Vec<String> = movies.get_displayed_attributes().await.unwrap();

Response: 200 Ok

List the settings.

  1. ["title", "description", "genre", "release_date"]

Update displayed attributes

POST

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

Update the displayed attributes of an index.

Path variables

VariableDescription
index_uidThe index UID

Body

An array of strings that contains attributes of an index to display.

More information about the body.

Example

cURL

JavaScript

Python

PHP

Ruby

Go

Rust

  1. curl \
  2. -X POST 'http://localhost:7700/indexes/movies/settings/displayed-attributes' \
  3. --data '[
  4. "title",
  5. "description",
  6. "genre",
  7. "release_date"
  8. ]'
  1. client.index('movies').updateDisplayedAttributes([
  2. 'title',
  3. 'description',
  4. 'genre',
  5. 'release_date',
  6. ])
  1. client.index('movies').update_displayed_attributes([
  2. 'title',
  3. 'description',
  4. 'genre',
  5. 'release_date'
  6. ])
  1. $client->index('movies')->updateDisplayedAttributes([
  2. 'title',
  3. 'description',
  4. 'genre',
  5. 'release_date'
  6. ]);
  1. client.index('movies').update_displayed_attributes([
  2. 'title',
  3. 'description',
  4. 'genre',
  5. 'release_date'
  6. ])
  1. displayedAttributes := []string{
  2. "title",
  3. "description",
  4. "genre",
  5. "release_date",
  6. }
  7. client.Index("movies").UpdateDisplayedAttributes(&displayedAttributes)
  1. let displayed_attributes = [
  2. "title",
  3. "description",
  4. "genre",
  5. "release_date"
  6. ];
  7. let progress: Progress = movies.set_displayed_attributes(&displayed_attributes).await.unwrap();

Response: 202 Accepted

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

This updateId allows you to track the current update.

Reset displayed attributes

DELETE

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

Reset the displayed attributes of the index to the default value.

Default value

All attributes found in the documents added to the index.

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/displayed-attributes'
  1. client.index('movies').resetDisplayedAttributes()
  1. client.index('movies').reset_displayed_attributes()
  1. $client->index('movies')->resetDisplayedAttributes();
  1. client.index('movies').reset_displayed_attributes
  1. client.Index("movies").ResetDisplayedAttributes()
  1. let progress: Progress = movies.reset_displayed_attributes().await.unwrap();

Response: 202 Accepted

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

This updateId allows you to track the current update.