Re: How to convert text relevance value to percentage values
Hi Xingliang,
I recently needed to do the same thing.
My solution was to run the FULLTEXT search and calculate the maximum relevance value generated and then finally to divide all relevance values by this number.
Here is my trick for computing the maximum relevance:
SET @rank:=0;
SELECT ..., IFNULL((@rank:=IF((@r:=(MATCH(...) AGAINST(...)))>@rank,@r,@rank))*NULL,@r) AS `Relevance` FROM table WHERE MATCH(...) AGAINST(...);
SELECT @rank;
This runs the FULLTEXT search as normal but keeps a tally of the maximum value in @rank to read after the search.
To convert the relevance values to percentages you'd value to iterate through the result rows and divide by the maximum value and multiply by 100. What works well is to calculate percentages on the fly when you are actually displaying the results to the user.
I don't know anyway of doing the full calculation during the search because there is no way to know what the maximum value is going to be. (There is no absolute maximum value, it changes with different searches.)
Best luck,
Jesse
Subject
Views
Written By
Posted
8895
November 06, 2006 10:46PM
Re: How to convert text relevance value to percentage values
8122
March 30, 2007 06:39PM
10090
May 03, 2007 07:46AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.