For Programmers: Free Programming Magazines  


Home > Archive > PHP Programming > January 2005 > MYSQL Fulltext relevance value - need php code









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author MYSQL Fulltext relevance value - need php code
Hal Halloway

2005-01-27, 8:55 am

How do I change a MYSQL Fulltext relevance value to: 0 to 100%. I'm just
thinking about usability for the "average" user - maybe they would like
to know...and would not understand the raw value.

Any snips, ideas or links appreciated.

Thanks
Dani CS

2005-01-27, 8:55 am

Hal Halloway wrote:
> How do I change a MYSQL Fulltext relevance value to: 0 to 100%. I'm just
> thinking about usability for the "average" user - maybe they would like
> to know...and would not understand the raw value.
>
> Any snips, ideas or links appreciated.
>
> Thanks


Order by relevance, assign 100% to the highest value and then calculate
the proportional value for the rest of relevances:


sort($relevances);

$factor = $relevances[0] * 100;

for($i = 0; $i < count($relevances); $i++) {

$relevances[$i] /= $factor;
}


Of course this assumes that the best result gives an exact match with
the query string. To make this assumption true one could add an
ephemeral row to the table with the query string by itself, just before
the query is sent. It sounds rather clumsy to me, tough.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com