I have a database with about 300 pages. I've written a search-function, so users can search in columns title, keywords and text for what they are looking for. (This happens automatically)

I have just added a FULLTEXT on these columns and started to experiment with the queries like: PHP:


mysql_query
("SELECT * , MATCH (Title,Text,Keywords) AGAINST
('$keywords') AS score FROM page WHERE MATCH (Title,Text,Keywords)
AGAINST ('$keywords') AND Intranet = '0'
ORDER BY score DESC LIMIT 0,20"
);
// $keywords are the search-terms from a <form>
if(!isset($scorehigh)){ $scorehigh = $score; }
// set highest score ( = 100%)
$score2 = number_format((($score / $scorehigh)* 100),0) . "%";
// $score2 is calculated as in procent against the highest score


How can I use the $score = relevance correctly? The score isn't between 0 and 1, but - depending on the number of searchterms - can run up to 5 or 6.

And I don't know what the logic is.
Let me explain the problem:

Say I have 5 searchterms, and there are 2 pages. One of them has 4 of the 5 in the text/title/keywords and the other one has 3 out of five.
Most logically, the first one will end up at the top of the list.
However, it will appear as 100% --- while the user entered at least one word that wasn't on the page. So, the score shouldn't be 100%, but 80%.

Basically:
How can you correctly use / calculate a relevance-score?
(is there a way to calculate the maximum relevance-score first?)

Any help is appreciated!
Jazz