API Reference / API Parameters / restrictSearchableAttributes
Type: list of strings
Engine default: all attributes in searchableAttributes
Parameter syntax
'restrictSearchableAttributes' => [
  'attribute'
]

Can be used in these methods:

About this parameter

Limit the search for a given query to a subset of your searchable attributes.

Usage notes

  • This setting is a search parameter, and only affects searches that specify it.
  • Only works when searchableAttributes isn’t empty or null.

You can’t use this setting:

Examples

Search on a restricted set of attributes

In this example, let’s consider that searchableAttributes contains ['title', 'author', 'publisher', 'content'], but we only want to search in title and author

1
2
3
4
5
6
$results = $index->search('query', [
  'restrictSearchableAttributes' => [
    'title',
    'author'
  ]
]);
Did you find this page helpful?