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

  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. index.get_displayed_attributes
  1. client.Settings("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

  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. 'release_date',
  5. 'rank',
  6. 'poster'
  7. ])
  1. $client->index('movies')->updateDisplayedAttributes([
  2. 'title',
  3. 'description',
  4. 'genre',
  5. 'release_date'
  6. ]);
  1. index.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.Settings("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

  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. index.reset_displayed_attributes
  1. client.Settings("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.