How to create percentages of fulltext relevance scores?

Instead of the arbitrary numbers that are returned by fulltext scores, how can I take the highest and lowest returned and make them percentages?

I would like to keep the processing within mysql queries, because the size of result-sets bog down post-processing in PHP.
voltraderAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

virmaiorCommented:
you really can't create accurate percentages... you can create comparitive percentages but what would they mean?

simple prefix your SELECT query
with a CREATE TEMPORARY TABLE `tablename`

SELECT @maxscore := MAX(score) FROM `tablename` WHERE 1
then: UPDATE `tablename` SET score = score / @maxscore

(assuming score is the arbitrary value that MySQL gives you).

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
voltraderAuthor Commented:
I see what you mean; I can only create comparitave %s. The MAX(score) is probably the only number I need.

My fulltext select queries frequently return lots of results. I would have to UPDATE the temporary table for as many results as are returned, which seems like a waste of cycles.

Could I do something like this?

1. First find the MAX score
SELECT @maxscore:=MAX(MATCH ('table') AGAINST ('keyword')) AS max_score FROM table_1 WHERE
MATCH('table') AGAINST ('keyword')

2. Do the % calc within the query
SELECT *, MATCH ('table') AGAINST ('keyword'))/@maxscore AS individual_score FROM table_1 WHERE
MATCH('table') AGAINST ('keyword')

Or is there a more efficient way?

Thanks
virmaiorCommented:
you could i guess.
but the main performance hit you're suffering is from regenerating the query contents.
you're not really saving any processing by foregoing the temp table.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.