Re: MySQL or PHP Trick to get most relevant results?
| From: | Mark Maggelet | Date: | Wed, 08 Nov 2000 23:47:50 +0000 |
| Subject: | Re: MySQL or PHP Trick to get most relevant results? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-24406@lists.php.net to get a copy of this message | ||
On Wed, 8 Nov 2000 14:24:35 -0800 (PST), jeremy brand
(jeremy@nirvani.net) wrote:
>In MySQL:
>
>1) you could build a reverse index of key words.
>2) you could use the mysql >= 3.23.23 text indexing functions
yes, you could use a fulltext index but the results I've seen are a
little weird, there's no guarantee you'll get the results in the
order you want them.
>3) (ouch) you could do a "like" clause.
ouch, but if the number of records is manageable it would be ok
To get the kind of relevancy I think you're looking for you could do
something like:
select keywords,(keywords='$keyword') as exact
from table where keywords like '%$keyword%' order by exact desc;
- Mark
>-jeremy brand
> http://www.JeremyBrand.com/Jeremy/Brand/Jeremy_Brand.html for
> more
>---------------------------------------------------------------------
> We cannot do everything at once, but we can do something at once.
> -- Calvin Coolidge
>
>On Wed, 8 Nov 2000, Roy Nasser wrote:
>
>> Date: Wed, 8 Nov 2000 20:23:42 -0300
>> From: Roy Nasser <roy@vem.ca>
>> To: "Php (E-mail)" <php-general@lists.php.net>
>> Subject: [PHP] MySQL or PHP Trick to get most relevant results?
>>
>> Hi,
>>
>> I am searching through a database with a text field... I would
>>like,
>> however, to match some things such:
>>
>> Database contains:
>> lollypop
>> Chocolate cake
>> steak
>> cake
>>
>>
>> When i query for "steak" I should get "steak" returned.
>> When i query for "chocolate" I should get "Chocolate cake"
>>returned.
>> When i query for "cake" I should get "cake" and "chocolate
>> cake"
>>returned
>> (in that order).
>> When i query for "lollypop" I should get "lollypop" returned.
>>
>>
>> Is there any ideas of ways to do this? Thanks!
>>
>> Roy
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
>> For additional commands, e-mail: php-general-help@lists.php.net
>> To contact the list administrators, e-mail: php-list-
>>admin@lists.php.net
>>
>>
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
>For additional commands, e-mail: php-general-help@lists.php.net
>To contact the list administrators, e-mail: php-list-
>admin@lists.php.net