Searching
You can search in aSearchable 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 thewhere 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
where method supports the following operators: <, <=, =, !=, >=, >.
Search with numerical range filters
ThewhereBetween method filters results for which the provided field falls between the given range:
PHP
Search with multiple filter values
ThewhereIn method filters results for which the value of the provided field is part of the given array:
PHP
Search with locational filters
ThearoundLatLng method adds a geolocation parameter to the search request.
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
Thewith method gives you complete access to customize search API parameters.
PHP
Retrieve the number of hits
Thecount method returns the number of hits the query matches:
PHP
Retrieve hit metadata
You can use thescoutMetadata 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 aroundLatLng parameter.
PHP
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