Skip to main content
You can search in a Searchable class using the search method. The search method accepts a single string to search in your Searchable class index:
PHP
You can also search with pagination, and work with soft deleted models. To learn more, see the Laravel Scout documentation.

Search with numerical filters

You can use the where method to filter your search results. With Scout Extended, this method shares the same API as the Laravel Query Builder, so you can filter results either with a comparison or a numerical range:
PHP
The where method supports the following operators: <, <=, =, !=, >=, >.

Search with numerical range filters

The whereBetween method filters results for which the provided field falls between the given range:
PHP

Search with multiple filter values

The whereIn method filters results for which the value of the provided field is part of the given array:
PHP
The whereNotIn method filters results for which the value of the provided field is not part of the given array:
PHP

Search with optional filters

The whereOptional method adds an optional filter to the search request. Unlike where, optional filters don’t exclude results: matching records rank higher instead.
PHP

Search with locational filters

The aroundLatLng method adds a geolocation parameter to the . You can define a point with its coordinates. This method is syntactic sugar, and you can use the method with to specify more location details such as aroundLatLng and aroundRadius.
PHP

Search with custom search parameters

The with method gives you complete access to customize search API parameters.
PHP
Don’t pass the filters parameter through the with method: Scout Extended computes filters from your where, whereIn, and whereNotIn clauses and overwrites any value you set manually. Express all your filter conditions with those methods instead.

Retrieve the number of hits

The count method returns the number of hits the matches:
PHP

Retrieve hit metadata

You can use the scoutMetadata method to retrieve an array with more information about any hit. The key _highlightResult holds all the highlighted attributes. By default, Algolia highlights all the searchable attributes. You can change this with the attributesToHighlight parameter.
PHP
If you set the getRankingInfo search parameter to true, the _rankingInfo response field holds detailed ranking information. It lets you see which ranking criteria played a role in selecting each model:
PHP
Last modified on July 23, 2026