Feb 8, 2022
0
Level 5
Best Practice Scout and Algolia Multiple Search Terms
Hi Guys
I have set up server side search over a model for one search term, this is actioned in the index method of the controller. I now want to add check boxes or date ranges for various model attributes for enhancing the search functionality.
if (!empty($request['searchterm']))
{
$articles = Article::search($request['searchterm'])->where('live', '1')->orderBy('created_at')->get();
}
Is there a best way to do this so that it is tidy? Should it be in the controller? I can see from the docs that I can use facetFilters, should I work out a way to build these array's from form data?
index.search('', {
facetFilters: [["author:Stephen King", "genre:Horror"], "publisher:Penguin"]
});
I've had a look around laracast and the internet but most examples don't deal with 10 - 20 different filters. Any help would be appreciated.
Please or to participate in this conversation.