00 Votes

MySQL Full Text Search only finds words with a length of at least 4 characters

Question by MediMan | 2012-10-14 at 17:20

I have implemented a MySQL full text search for a small web project. Thereby, I have strictly followed the instructions, I have found on the internet, but, however, it does not work as it should. It just does not find words less than 4 letters! There are many shortcuts on my website with 3 letters, which are now, of course, excluded from the search.

So far, my MySQL query looks like this:


What do I have to change to make it work?

00 Votes

Your MySQL query is already correct, you do not have to change anything. What caused the exclusion of all words under 4 letters is a setting of MySQL, which limits the minimum word length of a full-text search to 4 letters by default.

In your MySQL system variables, there is somewhere the line:

ft_min_word_len = 4

This stands for "Full Text Minimum Word Length" and provides exactly the behavior excluding words with 3 letters as you have described. If you change this value and start your MySQL server again, and then perform a "REPAIR TABLE" to set up the index with the new settings, you can change this word length. I have described this in more detail in my tip Change Minimum Word Length in MySQL Full-Text Search

Problems arise only, if we can not change the MySQL settings, for example, if we are hosting the homepage on a shared hosting provider, which do not allow to change the settings. For this case, it can still be worked with a combination of LIKE and the full-text search.
2012-10-14 at 19:26

ReplyPositive Negative

Related Topics

The Askingbox Search

Info | 0 Comments

MySQL: Sort by Relevance

Question | 1 Answer

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.


Ask your own question or write your own article on askingbox.com. That’s how it’s done.