Updated post, added some markup for better readability
First off you can create a view in your DB that will hold concatenated game|title + video|title, this will make things easier. Then simply search the view.
jarektkaczyk said:
First off you can create a view in your DB that will hold concatenated game|title + video|title, this will make things easier. Then simply search the view.
Thank you very much for the reply! This will solve a large part of my problem. I do still have another problem of wich i'm not entirely sure if it will be easy to create.
To give a good example there is a games called "Grand Theft Auto V", which people often used to write like "GTA", "GTA 5" or "Grand theft 5".
Would this be a good solution? :
<?php
/ ** TABLE videos **/
ID | search_col
----------------
1 | Grand Theft V Trailer GTA V GTA 5 Grand Theft 5
/**-------------- **/
$userInput = 'GTA V Trailer';
// Array ( 'GTA', 'V', 'Trailer' )
$keywords = explode( ' ', $userInput);
$video = Video::query();
foreach($keywords as $keyword){
$video->where('search_col', 'LIKE', '%'. $keyword .'%');
}
$videos = $video->get();
For best user experience you could setup dictionary and use it with every search query. Then whenever a user searches for GTA 5 or GTA5 or GTA V or grand theft auto etc.. you translate it to grand theft auto 5 (entry in the db). It works like 'did you mean ...' in google and other serach engines or apps. Additionally you may want to run string comparison to sort the results as best for the user.
The query looks fine.
jarektkaczyk said:
For best user experience you could setup dictionary and use it with every search query. Then whenever a user searches for GTA 5 or GTA5 or GTA V or grand theft auto etc.. you translate it to grand theft auto 5 (entry in the db). It works like 'did you mean ...' in google and other serach engines or apps. Additionally you may want to run string comparison to sort the results as best for the user.
The query looks fine.
Thanks! This seems like the best solution for my problem :)
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community