Web Development

MySQL fulltext search for 3 char words

If you are familiar with full text searching in MySQL, you will be surprised to know that MySQL doesn’t index words containing 3 or less characters by default. Searching such words ends up with no result. I am sure sometime you also suffered from the same problem. If you are not familiar with this default behavior of MySQL you may spend hours after hours trying to find out what went wrong. Well, here is the solution for you :D

There is a system option named “ft_min_word_len” by which you can define the minimum length of words to be indexed. You need to set value to this configuration directive in your MySQL configuration file which is found under “/etc/mysql” or “/etc”. In windows you can look under windows directory or MySQL home folder. You need to set this value under [mysqld] section.

[mysqld]
ft_min_word_len=3

There is also a handy method if you don’t want to change in your configuration file. Just start your mysql daemon with the following command

mysqld --ft_min_word_len=3

You may also need to rebuild your index.

Now you can search words with 3 characters in your full text queries.

About the author

Written by .

If you found this post useful you may also want to check these out:

  1. Hightlight or Censor Words in PHP
  2. Implementing High Availability in MySQL
  3. How to Install MySQL 5.0 on Linux
  4. Replacing Text in a MySQL Database Using PHP
  5. Showing MySQL Results in Pages
  6. Setting Up Apache, PHP & MySQL On Windows
  • senos

    This doesn’t work for me, there is no file in the /etc/ folder except for one called ftpquota