laravellaravel-scout

Advanced Laravel Search Functionality Using Scout


I have a Model named Profile in my project and i want to search user's full name through the records using Laravel Scout.

Search Function

public function SearchUser(Request $request)
{
    $searchProfileQuery = Profile::search($request->input('query'))->get();
    
    return view('users/search-result', compact('searchProfileQuery'));
}

Let's say there are 2 records :

Current Condition :

QUESTION :

Thanks in advance.


Solution

  • If you use the database engine as laravel scout driver, the comparison is done by executing a SQL LIKE query against the desired fields as described here: https://laravel.com/docs/9.x/scout#database-engine

    What you'd like to have is an additional feature that is not part of the database engine. If switching to another engine like algolia is possible, please have a look at the Algolia typo tolerance documentation: https://www.algolia.com/doc/api-reference/api-parameters/typoTolerance/