I am using a full text query with MySql version 5.0.45 and I am trying to optimize it for my needs. The score system was working fine, however because I have added a stemmer before the input now, I had to use a wildcard on the search term. The problem is that now a stemmed word will match but return a score of 0. (ie: "restriction" gets stemmed to "restrict" and will still get recognized as a match but with a score of 0)
Here's the query:
$escaped_string = mysql_real_escape_string($string);
$query = "SELECT DISTINCT A1.item_ID, item,
4.0 * (match (`item_1`) against ('". $escaped_string."*'))
+ 3.5 * (match (`item_2`) against ('".$escaped_string."*'))
+ 3.0 * (match (`item_3`) against ('".$escaped_string."*'))
+ 2.5 * (match (`item_4`) against ('".$escaped_string."*'))
+ 1.5 * (match (`item_5`) against ('".$escaped_string."*'))
as score
FROM Items A1 LEFT OUTER JOIN Inventory A2 ON A1.item_ID=A2.item_ID
WHERE MATCH(`item_1`, `item_2`,`item_3`,`item_4`,`item_5`) AGAINST ('".$escaped_string."*' IN BOOLEAN MODE)
ORDER BY score DESC
LIMIT 200";
The score calculates perfectly before when it's ('".$escaped_string."'))
but not when you add the wildcard *. In both cases the matching works fine, the problem is that the score does not calculate if there is a wildcard.
Any help on this would be appreciated! (I hope I'm doing this mostly right)