(all string attributes)
'searchableAttributes' => [ 'attribute1', 'attribute2, attribute3', // both attributes have the same priority 'unordered(attribute4)' ]
About this parameter
The complete list of attributes used for searching.
This setting is crucial for two reasons:
It narrows the search area to specific attributes. By selecting which attributes can be searched, you control what the search engine looks at. Avoid including attributes that don’t help with searching, such as URLs or images. For more information, see Searchable attributes.
It sets a priority order for the attributes. The position of attributes in the list of
searchableAttributesdetermines their priority in the search. Records matching higher-priority attributes score better than those matching lower-priority attributes.
searchableAttributes parameter rebuilds your index.
If you need near real-time indexing, avoid changing the index configuration during high-traffic times.
- By default, or if you set
searchableAttributesto an empty list, Algolia searches in all attributes. This turns off the Attributes ranking criterion.
- To determine how Algolia searches within an attribute, use modifiers. By default, the engine favors matches at the beginning of an attribute, but you can change it to ignore positioning and consider any match within an attribute of equal importance.
- Attributes with the same priority
- To make two attributes equally important, include them in the same comma-separated string.
Attributes with the same priority as others are always
- Nested attributes
- When you specify an attribute with nested attributes, Algolia indexes them all.
If you don’t want to search the entire nested attribute,
you can reference a child attribute, such as
There’s no limit to the number of attributes in the list, but having many attributes slows down calls to
getSettings. This can make the Algolia dashboard slower and less responsive.
Ignores the position of the match within the attribute.
If you add
In this example, Algolia searches for matches in the
Matches in the
title attribute rank higher than matches in the
Matches in the
alternativeTitle attributes rank equally.
Matches at the start of an attribute rank higher, except in the
where all matches rank equally. The
personal child attribute is searchable.
1 2 3 4 5 6 7 8 $index->setSettings([ 'searchableAttributes' => [ 'title,alternative_title', 'author', 'unordered(text)', 'emails.personal' ] ]);