How to Change MySQL FULLTEXT Index Minimum and Maximum Length of Words

MySQL database has built-in full-text search capability that allows SQL queries to perform search quickly using MySQL database engine. The full-text search capability depends on the FULLTEXT index which is been created on various table fields or columns. However, some search queries may not return the experted results or datasets, even though the data is verified to exists on full-text search, especially on short keywords or search terms.

The problem probably lies on the default minimum length of words indexed by FULLTEXT index which is set as 4 characters. Thus, when attempting to search via full-text index, the short words are not indexed, and hance not return in search results.

By default, the minimum value for length of word to be indexed in FULLTEXT index is four characters, while the default maximum length of words to be indexed in FULLTEXT index is varies depending on version of mySQL server. To increase the number of words indexed and searchable, especially shorter words such as three-character words, administrator can reduce the minimum or increase the maximum length of words to be indexed by using ft_min_word_len and ft_max_word_len system variables.

For example, for FULLTEXT index to index the three-character words, or 3-letter text, add in the following line to set the lower value for ft_min_word_len variable under [mysqld] section to an option file, i.e. my.cnf:

[mysqld]
ft_min_word_len=3

Save the file, and then restart the MySQL server. After changing either value of full-text variable, which both affects indexing, the FULLTEXT indexes must be rebuilt. The following command to do a quick repair operating is sufficient to rebuild the indexes:

mysql> REPAIR TABLE tbl_name QUICK;

Note that each and every table that contains any FULLTEXT index must be repaired with SQL command above. Also do not use myisamchk (unless you have also defined the full-text parameter values in [myisamchk] section) to perform the rebuilt as the full-text parameters are only known to mysqld server. If rebuild is not done, queries for the table may yield incorrect results, and modifications to the table will cause the server to see the table as corrupt and in need of repair.



2 Responses to “How to Change MySQL FULLTEXT Index Minimum and Maximum Length of Words”

  1. chichilatte
    May 11th, 2008 02:49
    1

    Yes, thnks, but where is this mysterious config file “my.cnf”?

  2. admin
    May 11th, 2008 08:21
    2

    Depends. Normally it’s located in /etc

Leave a Reply

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribe to comments feature has been disabled. To receive notification of latest comments posted, subscribe to Tip and Trick Comments RSS feed or register to receive new comments in daily email digest.
Custom Search

Incoming Search Terms for the Article

mysql rebuild fulltext index - mysql fulltext index - rebuild fulltext index mysql - mysql rebuild index - mysql minimum word length - mysql update fulltext index - mysql rebuild FULLTEXT indexes - rebuild fulltext indexes MySQL - fulltext index mysql - mysql minimum length - mysql index rebuild - mysql rebuild fulltext - mysql rebuild full text index - mysql fulltext index length - rebuild index MYSQL - rebuild fulltext mysql - mysql text index length - mysql fulltext - minimum word length fulltext - mysql fulltext minimum characters - wm6 mysql - mysql change index length - mysql fulltext length - length mysql - mysql fulltext ft_min_word_len - change mysql fulltext length - mysql full text keyword length - all - fulltext min chars - ft_min_word_len change - rebuild mysql fulltext index - fulltext search minimum length - mysql change search minimum length - minimum and maximum word length full-text parameters - mysql fulltext minimum word length - fulltext mysql - how to rebuild FULLTEXT index MySQL - fulltext length - mysql minimum search 3 chars help - mysql full text search 3 chars - full text index mysql 3 letter words - update fulltext index mysql - mysql 3 letter fulltext - mysql full text search minimum length 3 - mysql maximum indexes - mySQL full text search 3 letter words - how to change minimum word length for full text search in mysql - set mysql full text search minimum word length - mysql full text search min length - mysql word length -