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.

To learn more about displayed 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 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

JS

Python

PHP

Java

Ruby

Go

Rust

Swift

Dart

  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").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();
  1. client.index("movies").getDisplayedAttributes { (result: Result<[String], Swift.Error>) in
  2. switch result {
  3. case .success(let displayedAttributes):
  4. print(displayedAttributes)
  5. case .failure(let error):
  6. print(error)
  7. }
  8. }
  1. await client.index('movies').getDisplayedAttributes();

Response: 200 Ok

List the settings.

  1. [
  2. "title",
  3. "description",
  4. "genre",
  5. "release_date"
  6. ]

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

JS

Python

PHP

Java

Ruby

Go

Rust

Swift

Dart

  1. curl \
  2. -X POST 'http://localhost:7700/indexes/movies/settings/displayed-attributes' \
  3. -H 'Content-Type: application/json' \
  4. --data-binary '[
  5. "title",
  6. "description",
  7. "genre",
  8. "release_date"
  9. ]'
  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. Settings settings = new Settings();
  2. settings.setDisplayedAttributes(new String[]
  3. {
  4. "title",
  5. "description",
  6. "genre",
  7. "release_date"
  8. });
  9. client.index("movies").updateSettings(settings);
  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();
  1. let displayedAttributes: [String] = ["title", "description", "release_date", "rank", "poster"]
  2. client.index("movies").updateDisplayedAttributes(displayedAttributes) { (result: Result<Update, Swift.Error>) in
  3. switch result {
  4. case .success(let update):
  5. print(update)
  6. case .failure(let error):
  7. print(error)
  8. }
  9. }
  1. await client.index('movies').updateDisplayedAttributes([
  2. 'title',
  3. 'description',
  4. 'genre',
  5. 'release_date'
  6. ]);

Response: 202 Accepted

  1. { "updateId": 1 }

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

JS

Python

PHP

Java

Ruby

Go

Rust

Swift

Dart

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

Response: 202 Accepted

  1. { "updateId": 1 }

This updateId allows you to track the current update.