If I was you I would first search the most relevant table and seems in this case its items, if 0 results then I would search tags and if 0 results I would search categories.
Dec 6, 2016
1
Level 1
Full text search, search from multiple tables
I'm building a small ecommerce app and I'm trying to implement a full text search (product search) but having trouble where to start because the search function should search from the 3 tables. I have 3 tables named 'categories, tags and items'. Surely I can use 'LIKE' query in each table query like,
$items = items::where('item_name','LIKE', $request->search)->get();
$items = categories::where('item_name','LIKE', $request->search)->get();
$items = tags::where('item_name','LIKE', $request->search)->get();
and then merge 3 returns collections.
Is there a best way to achieve this? or any search engine extension for Laravel 5.3 that you can suggest which can cater my needs?
Please or to participate in this conversation.