Algorithms are complex.
Unreal tournament 2004 cheats
I'll just number the words 1-4 for ease.
You could set up a search like this:
where
keywords like '%1 2 3 4%' OR
keywords like '%1%' OR
..
keywords like '%4%'
ORDER BY
IF(keywords like '%1 2 3 4%',16,0) +
IF(keywords like '%1%',4,0) +
IF(keywords like '%2%',4,0) +
IF(keywords like '%3%',4,0) +
IF(keywords like '%4%',4,0)
DESC
[NOTE: you might also be able to remove the where clause in some cases and just select * to see if you get better speed. Since results are desc, you can use php to decide if the first record has 0 as a value]
so you see that something having all four would rank the highest numerically and be at the top.
I don't know how to get a COUNT of matches in a string, which ironically I was searching for just before your post.
You would need tofigure out the weighting of the number values.
Also, consider this phrase:
a red pig in scarlet clothing
a and in are not significant, and you can "split" the string into "red pig" and "scarlet clothing" using a good regex pattern - so some pre parsing would be helpful so that you don't kill your db with a long query.
Those are the two main concepts I'm aware of in searching. However you might also look at soundex() as a function and other similar at dev.mysql.com.
If anyone has a solution along these lines, I'm signed upf for the thread :-)
Sam