MYSQL Fulltext relevance value - need php code

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
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.


Re: MYSQL Fulltext relevance value - need php code

Hal Halloway wrote:
Quoted text here. Click to load it

Order by relevance, assign 100% to the highest value and then calculate
the proportional value for the rest of 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.

Site Timeline