Field Properties
- The : Attributes whose fields are searched for matching query words.
- The displayed attributes list: Attributes whose fields are displayed in documents.
This means that by default, every field in a document is searchable and displayed. These properties can be modified in the .
A field can either be searchable or non-searchable.
When you perform a search, all searchable fields are searched for matching query words and used to assess document relevancy, while non-searchable fields are ignored entirely. By default, all fields are searchable.
Non-searchable fields are most useful for internal information that’s not relevant to the search experience, such as URLs, sales numbers, or ratings used exclusively for sorting results.
TIP
Even if you make a field non-searchable, it will remain stored in the database and can be made searchable again at a later time.
MeiliSearch uses an ordered list to determine which attributes are searchable. The order in which attributes appear in this list also determines their impact on relevancy, from most impactful to least.
- It designates the fields that are searchable.
- It dictates the .
There are two possible modes for the searchableAttributes
list.
Default: Automatic
By default, all attributes are automatically added to the searchableAttributes
list in their order of appearance. This means that the initial order will be based on the order of attributes in the first document indexed, with each new attribute found in subsequent documents added at the end of this list.
This default behavior is indicated by a searchableAttributes
value of ["*"]
. To verify the current value of your searchableAttributes
list, use the .
If you’d like to restore your searchable attributes list to this default behavior, simply set searchableAttributes
to an empty array []
or use the .
Manual
You may want to make some attributes non-searchable, or change the after documents have been indexed. To do so, simply place the attributes in the desired order and send the updated list using the update searchable attributes endpoint.
WARNING
Be aware that after manually updating the searchableAttributes
list, subsequent new attributes will no longer be automatically added unless the settings are .
Example
client.index('movies').updateSettings({
searchableAttributes: [
'title',
'description',
'genre'
]
})
client.index('movies').update_settings({
'searchableAttributes': [
'title',
'description',
'genre'
]})
$client->index('movies')->updateSearchableAttributes([
'description',
'genre'
]);
searchableAttributes := []string{
"title",
"description",
"genre",
}
client.Settings("movies").UpdateSearchableAttributes(searchableAttributes)
let searchable_attributes = &[
"title",
"description",
"genre"
];
let progress: Progress = movies.set_searchable_attributes(searchable_attributes).await.unwrap();
The fields whose attributes are added to the are displayed in each matching document.
Documents returned upon search contain only displayed fields.
By default, all field attributes are set as displayed.
Therefore, if a field attribute is not in the displayed-attribute list, the field won’t be added to the returned documents.
This list can be restricted to a selected set of attributes in the settings.
Example
Suppose you manage a database that contains information about movies. By adding the following settings, documents returned upon search will contain the fields title
, description
, release_date
and genre
.
$ curl \
-X POST 'http://localhost:7700/indexes/movies/settings' \
--data '{
"displayedAttributes": [
"title",
"description",
"genre",
"release_date"
]
'displayedAttributes': [
'title',
'description',
'genre',
'release_date'
]})
$client->index('movies')->updateDisplayedAttributes([
'title',
'description',
'genre',
'release_date'
]);
index.update_settings({
displayedAttributes: [
'title',
'description',
'genre',
'release_date'
]
})
let displayed_attributes = &[
"title",
"description",
"genre",
"release_date"
];
let progress: Progress = movies.set_displayed_attributes(displayed_attributes).await.unwrap();
All fields are stored. This behavior cannot be changed.