Re: Search thoughts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux