I've bee struggling way too long on this case so I decided to reach for some help and pray for some answers. Basically I'm trying to build a search engine. At first it was just a simple like clause on several fields which worked great, but we're trying to extend and now trying to match each word from a phrase. The problem I'm at right now is as follows: Lest say we have a search string "Baked Cookies" this will search our db for like "Baked Cookies" or like "baked" or like "cookies" on several fields. What I'm trying to achieve is the have the results on the whole phrase on top, which works if I do something like
$ord = "field like \"%Baked Cookies\" ASC";
$query->orderByRaw($ord);
But it's really, really slow. Adding this makes my query like 8 times slower. So any suggestions on how this should be handled ?
Thank you!