mysqlmatchagainst

MySQL Match Against giving 2 different results on 2 servers


I have a local dev version of a website that I'm coding a search function for and running into a problem where the the result I'm getting on my PC is different to the server. The problem is to do with there being a slash in the data. For example the field contains something like

Amazing Product Name/Exp

And running the following query on both servers:

SELECT name, MATCH(name) AGAINST('amazing,name,exp' IN BOOLEAN MODE) AS relevance 
FROM `product_description` 
WHERE MATCH(name) AGAINST('amazing,name,exp' IN BOOLEAN MODE)

On my PC the relevance field shows 2, whereas on the server it's showing 3 as it should. The data on my PC as a dump from the server. Both are using the same character sets. MySQL versions are different though, PC: 5.5.39, Server: 5.1.73-1-log but I wouldn't think that would make a difference?

I compared the charset xml files on each and they are the same. I don't believe the server source code has been changed and recompiled at all. this is based on what I've read here: http://dev.mysql.com/doc/refman/5.5/en/fulltext-fine-tuning.html

I'd have thought that the default behaviour for this would be that the slash would be treated as a space or word separation character or whatever.

Anyone shed some light on why they might differ?


Solution

  • I found the reason, I was focusing on the slash being the issue but the real reason was the ft_min_word_len mysql system variable. The default is 4 but the server was 3. I edited the my.ini file on my PC and added

    ft_min_word_len = 3
    

    restarted mysql and reindexed the data and now it's showing the same results as the server.