API Reference / API Parameters / restrictSearchableAttributes
Feb. 26, 2019

restrictSearchableAttributes

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

Can be used in these methods:

About this parameter

Restricts a given query to look in only a subset of your searchable attributes.

This setting overrides searchableAttributes for specific searches.

Usage notes:

  • This setting is a query-level setting, affecting only the search that specifies it.
  • searchableAttributes must not be empty nor null for restrictSearchableAttributes to be applied.

Examples

Search on a restricted set of attributes

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

1
2
3
4
5
6
$results = $index->search('query', [
  'restrictSearchableAttributes' => [
    'title',
    'author'
  ]
]);

Did you find this page helpful?