Searchable attributes
Child route of the settings route.
The values associated with attributes in the searchableAttributes
list are searched for matching query words. The order of the list also determines the attribute ranking order.
Searchable attributes can also be updated directly through the global settings route along with the other settings.
To learn more about searchable 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 searchable attributes
GET
/indexes/:index_uid/settings/searchable-attributes
Get the searchable 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/searchable-attributes'
client.index('movies').getSearchableAttributes()
client.index('movies').get_searchable_attributes()
$client->index('movies')->getSearchableAttributes();
client.index("movies").getSearchableAttributes();
client.index('movies').searchable_attributes
client.Index("movies").GetSearchableAttributes()
let searchable_attributes: Vec<String> = movies.get_searchable_attributes().await.unwrap();
client.index("movies").getSearchableAttributes { (result: Result<[String], Swift.Error>) in
switch result {
case .success(let searchableAttributes):
print(searchableAttributes)
case .failure(let error):
print(error)
}
}
await client.index('movies').getSearchableAttributes();
Response: 200 Ok
List the settings.
[
"title",
"description",
"genre"
]
Update searchable attributes
POST
/indexes/:index_uid/settings/searchable-attributes
Update the searchable attributes of an index.
WARNING
Due to an implementation bug, manually updating searchableAttributes
will change the displayed order of document fields in the JSON response. This behavior is inconsistent and will be fixed in a future release.
Path variables
Variable | Description |
---|---|
index_uid | The index UID |
Body
An array of strings that contains searchable attributes sorted by order of importance (arranged from the most important attribute to the least important attribute).
This means that a document with a match in an attribute at the start of the array will be considered more relevant than a document with a match in an attribute at the end of the array.
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/searchable-attributes' \
-H 'Content-Type: application/json' \
--data-binary '[
"title",
"description",
"genre"
]'
client.index('movies').updateSearchableAttributes([
'title',
'description',
'genre',
])
client.index('movies').update_searchable_attributes([
'title',
'description',
'uid'
])
$client->index('movies')->updateSearchableAttributes([
'title',
'description',
'genre'
]);
Settings settings = new Settings();
settings.setSearchableAttributes(new String[]
{
"title",
"description",
"genre"
});
client.index("movies").updateSettings(settings);
client.index('movies').update_searchable_attributes([
'title',
'description',
'genre'
])
searchableAttributes := []string{
"title",
"description",
"genre",
}
client.Index("movies").UpdateSearchableAttributes(&searchableAttributes)
let searchable_attributes = [
"title",
"description",
"genre"
];
let progress: Progress = movies.set_searchable_attributes(&searchable_attributes).await.unwrap();
let searchableAttributes: [String] = ["title", "description", "uid"]
client.index("movies").updateSearchableAttributes(searchableAttributes) { (result: Result<Update, Swift.Error>) in
switch result {
case .success(let update):
print(update)
case .failure(let error):
print(error)
}
}
await client.index('movies').updateSearchableAttributes([
'title',
'description',
'uid'
]);
A match in title will make a document more relevant than another document with a match in description.
Response: 202 Accepted
{ "updateId": 1 }
This updateId
allows you to track the current update.
Reset searchable attributes
DELETE
/indexes/:index_uid/settings/searchable-attributes
Reset the searchable 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/searchable-attributes'
client.index('movies').resetSearchableAttributes()
client.index('movies').reset_searchable_attributes()
$client->index('movies')->resetSearchableAttributes();
//Not yet implemented
client.index('movies').reset_searchable_attributes
client.Index("movies").ResetSearchableAttributes()
let progress: Progress = movies.reset_searchable_attributes().await.unwrap();
client.index("movies").resetSearchableAttributes { (result: Result<Update, Swift.Error>) in
switch result {
case .success(let update):
print(update)
case .failure(let error):
print(error)
}
}
await client.index('movies').resetSearchable_Attributes();
Response: 202 Accepted
{ "updateId": 1 }
This updateId
allows you to track the current update.