(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 critical to establishing excellent relevance for two main reasons:
- It limits the scope of a search to the listed attributes. Defining specific attributes as searchable gives you direct control over what information the search engine should look at. Some attributes contain URLs; others exist for display purposes only. Such attributes are not helpful for searching.
- It creates a priority order between attributes that the engine uses to improve relevance. The order in which the attributes appear determines their search priority. Records with matches in the first attribute(s) of the list score higher on the attribute criterion than records with matches in the second attribute(s), which score higher than records with matches in the third attribute(s), and so on.
Whenever you change this parameter, the engine rebuilds your entire index. If you need to do near real-time indexing, try not to change the setting during your peak-traffic times.
- Default/empty list: if you don’t use this setting, or use it with an empty list, the engine searches in all attributes.
- Ordering: in addition to creating attribute-level priority, you can also determine how the engine searches within an attribute. 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.
- Same priority: you can create the same priority for several attributes by setting them in the same comma-separated string. Attributes that are on the same priority as others are always
- Nested attributes: when you specify an attribute with nested attributes, the engine indexes them all. If you don’t want to search the entire attribute, you can reference a child attribute (such as
Any match anywhere in the attribute has the same weight.
If you add
If you set
1 2 3 4 5 6 7 8 $index->setSettings([ 'searchableAttributes' => [ 'title,alternative_title', 'author', 'unordered(text)', 'emails.personal' ] ]);