searchableAttributes setting to limit which fields are searchable and control their relative importance in the attribute ranking order. This also affects ranking rules that depend on attribute order.
Why configure searchable attributes
There are two main reasons to customize searchable attributes:- Improve relevancy: Fields listed earlier in the
searchableAttributesarray have a greater impact on relevancy. If a match is found in the first attribute, that document ranks higher than one where the match appears in a later attribute. - Improve performance: Reducing the number of searchable fields means Meilisearch has less data to scan during each query, which can speed up search on large datasets.
id, title, overview, genres, and release_date, you probably want title to carry the most weight, followed by overview and genres. The id and release_date fields are not useful for text search and can be excluded.
Check current searchable attributes
Retrieve the currentsearchableAttributes setting for an index:
["*"], meaning all attributes are searchable in their order of appearance.
Update searchable attributes
Set thesearchableAttributes list to control which fields are searchable and their ranking order. Fields listed first have the highest impact on relevancy:
title the most important searchable field, followed by overview, then genres. Fields not in the list (such as id and release_date) are no longer searchable.
Reset searchable attributes
ResetsearchableAttributes to its default value (["*"]), making all fields searchable again:
Restrict searchable attributes at query time
If you need to limit which attributes are searched for a specific query without changing the index setting, use theattributesToSearchOn search parameter:
title field for this request, regardless of the index-level searchableAttributes setting. The attributes specified must be a subset of the configured searchableAttributes.
For more details on how searchable and displayed attributes work together, see displayed and searchable attributes. For the full API reference, see get searchable attributes.