Forum Moderators: coopster

Message Too Old, No Replies

MySQL Boolean FullText Search Ordered by Relevance

Relevance score rather than Row Data returned.

         

Dayo_UK

3:41 pm on Sep 16, 2004 (gmt 0)



Ok, hopefully someone can help me here! (sorry if some of my tech words are wrong!)

I have a Mysql Boolean Full Text search on one of my sites which uses the following code:-

$Query = "SELECT * from $TableName where match (data) against ('+keyword, +keyword1' IN BOOLEAN MODE)";

$Result = mysql_db_query ($DBName, $Query, $Link);

while ($Row = mysql_fetch_array ($Result)){

echo etc etc

Which works fine - the Data I require from the table is stored in the $Row Array and I can pull this data and write it to the document.

However, I want to order the results by relevance so the code has been changed to:-


$Query = "SELECT match (data) against ('keyword, keyword1') as Relevance from $TableName Where Match (data) against ('+keyword, +keyword1' IN BOOLEAN MODE) HAVING Relevance > 0.2 Order by Relevance Desc";

$Result = mysql_db_query ($DBName, $Query, $Link);

while ($Row = mysql_fetch_array ($Result)){

echo etc etc

Now though the $Row array contains the relevance score rather than the data from the table. :(

Any ideas where the data from the table is now stored or where I have gone wrong?

SkyDog

4:08 pm on Sep 16, 2004 (gmt 0)

10+ Year Member



Try:

$Query = "SELECT *, match (data) against ('keyword, keyword1') as Relevance from $TableName Where Match (data) against ('+keyword, +keyword1' IN BOOLEAN MODE) HAVING Relevance > 0.2 Order by Relevance Desc";