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
/indexes/:index_uid/settings/displayed-attributes
Get the displayed attributes of an index.
Path variables
Variable | Description |
---|---|
index_uid | The index UID |
Example
<>
cURL
JS
Python
PHP
Java
Ruby
Go
Rust
Swift
Dart
curl \
-X GET 'http://localhost:7700/indexes/movies/settings/displayed-attributes'
client.index('movies').getDisplayedAttributes()
client.index('movies').get_displayed_attributes()
$client->index('movies')->getDisplayedAttributes();
client.index("movies").getDisplayedAttributes();
client.index('movies').get_displayed_attributes
client.Index("movies").GetDisplayedAttributes()
let displayed_attributes: Vec<String> = movies.get_displayed_attributes().await.unwrap();
client.index("movies").getDisplayedAttributes { (result: Result<[String], Swift.Error>) in
switch result {
case .success(let displayedAttributes):
print(displayedAttributes)
case .failure(let error):
print(error)
}
}
await client.index('movies').getDisplayedAttributes();
Response: 200 Ok
List the settings.
[
"title",
"description",
"genre",
"release_date"
]
Update displayed attributes
POST
/indexes/:index_uid/settings/displayed-attributes
Update the displayed attributes of an index.
Path variables
Variable | Description |
---|---|
index_uid | The 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
curl \
-X POST 'http://localhost:7700/indexes/movies/settings/displayed-attributes' \
-H 'Content-Type: application/json' \
--data-binary '[
"title",
"description",
"genre",
"release_date"
]'
client.index('movies').updateDisplayedAttributes([
'title',
'description',
'genre',
'release_date',
])
client.index('movies').update_displayed_attributes([
'title',
'description',
'genre',
'release_date'
])
$client->index('movies')->updateDisplayedAttributes([
'title',
'description',
'genre',
'release_date'
]);
Settings settings = new Settings();
settings.setDisplayedAttributes(new String[]
{
"title",
"description",
"genre",
"release_date"
});
client.index("movies").updateSettings(settings);
client.index('movies').update_displayed_attributes([
'title',
'description',
'genre',
'release_date'
])
displayedAttributes := []string{
"title",
"description",
"genre",
"release_date",
}
client.Index("movies").UpdateDisplayedAttributes(&displayedAttributes)
let displayed_attributes = [
"title",
"description",
"genre",
"release_date"
];
let progress: Progress = movies.set_displayed_attributes(&displayed_attributes).await.unwrap();
let displayedAttributes: [String] = ["title", "description", "release_date", "rank", "poster"]
client.index("movies").updateDisplayedAttributes(displayedAttributes) { (result: Result<Update, Swift.Error>) in
switch result {
case .success(let update):
print(update)
case .failure(let error):
print(error)
}
}
await client.index('movies').updateDisplayedAttributes([
'title',
'description',
'genre',
'release_date'
]);
Response: 202 Accepted
{ "updateId": 1 }
This updateId
allows you to track the current update.
Reset displayed attributes
DELETE
/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
Variable | Description |
---|---|
index_uid | The index UID |
Example
<>
cURL
JS
Python
PHP
Java
Ruby
Go
Rust
Swift
Dart
curl \
-X DELETE 'http://localhost:7700/indexes/movies/settings/displayed-attributes'
client.index('movies').resetDisplayedAttributes()
client.index('movies').reset_displayed_attributes()
$client->index('movies')->resetDisplayedAttributes();
//Not yet implemented
client.index('movies').reset_displayed_attributes
client.Index("movies").ResetDisplayedAttributes()
let progress: Progress = movies.reset_displayed_attributes().await.unwrap();
client.index("movies").resetDisplayedAttributes { (result: Result<Update, Swift.Error>) in
switch result {
case .success(let update):
print(update)
case .failure(let error):
print(error)
}
}
await client.index('movies').resetDisplayedAttributes();
Response: 202 Accepted
{ "updateId": 1 }
This updateId
allows you to track the current update.