I'm using MYSQL to generate a score for each result returned by a query. The results are then ordered by the score.
The part that doesn't seem to be working properly is when I'm trying to add a score for each tag that has been searched and the result is assigned to. So lets say I do a search for the tags "example", "test and "tag" and one of my results is assigned to the tags "example", "test", "someothertag" it should come up with a score of 10 since there are 2 matches.
What is actually happening is I'm getting a score of 5 if there is a match, regardless of how many tags are matched. and 0 if no tags are matched.
Here is an example of one of the queries that is generated from a search.
SELECT DISTINCT results.*,
(
5*(MATCH(tags.name) AGAINST('"self employed"' IN BOOLEAN MODE)) +
5*(MATCH(tags.name) AGAINST('"rental income"' IN BOOLEAN MODE)) +
5*(MATCH(tags.name) AGAINST('"commission income"' IN BOOLEAN MODE)) +
5*(MATCH(tags.name) AGAINST('"bankruptcy"' IN BOOLEAN MODE)) +
5*(MATCH(tags.name) AGAINST('"condo approval"' IN BOOLEAN MODE)) +
1*usefulness +
10*shares
) AS score
FROM results
INNER JOIN categories c on results.ID = c.RESULT_ID
INNER JOIN tags ON results.id = tags.result_id
WHERE c.name in ('purchase', 'condo', 'va')
AND ( tags.name = 'self employed' OR tags.name = 'rental income' OR tags.name = 'commission income' OR tags.name = 'bankruptcy' OR tags.name = 'condo approval' )
AND ( results.scope = 'all' OR results.scope = 'hi' )
AND published = 1
GROUP BY results.ID
having count(distinct c.c_id) = 3
ORDER BY score DESC
LIMIT 8 OFFSET 0