Mark Kelly wrote:
Hi.

On Saturday 19 July 2008, Richard Heyes wrote:
Currently the site in question uses a very basic LIKE in MySQL, eg
%blah%, but naturally this finds terms such as hjkblahbjkk - which is
not desired. Or such matches should be ranked lower than something that
matches the exact word blah.

I did this with 2 queries, and no need for messing with points etc (unless you particularly want to). Start with "LIKE 'word'" query and pull the results into a results array. Then do the same query but with "LIKE '%word%'" and loop through append the results to the results array. Use something like "if (!in_array($thisResult,$resultSet))" while appending to avoid duplicates.

Well no. LIKE is slow and so is in_array(). Admittedly it's not a busy site, but still.


How much traffic do you have and what's your hardware? Are your queries cached and subsequently repeated? Do you pre cache common queries?

Cheers.

--
Richard Heyes

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to