Online Chat
 Call Us: 
Browse Submit a Ticket
Advanced Search
Rss Categories

Correct search by codes, IDs, and short acronyms

Author: Edward Hardin Reference Number: AA-00543 Views: 4702 Last Updated: 05/17/2012 04:19 PM 0 Rating/ Voters

You may notice that by default you cannot search for words that consist of 3 characters or less. This usually makes you unable able to search for some strings that may be considered as a single word, but they are really not, e.g. IDs, codes, reference numbers, short acronyms, etc. It happens because, when full-text search index created for an article (or attachment, or any other searchable item), all symbols (e.g. points, slashes, hyphens, etc.) get replaced by whitespaces, for example you got this text:


its search index is this:


Since each part is 3 characters long, you will not find this text  using neither "AAA-BBB-111" for search phrase, nor "AAA BBB 111".

If you would like to be able to search for such strings, you need to decrease minimum length of words to be indexed in MySQL settings (my.ini). For that:

Add this line under the [mysqld] section:

And the same line under the [myisamchk] section:

If there is no [myisamchk] section in the my.ini yet, you just need to add it at the end of the file and place ft_min_word_len=3 on the next line:


The code above sets minimum length of words to be searched to 3. You can try to decrease it to 2, but be careful because search may start to return inaccurate results.

Then restart the MySQL server.

Now you need to rebuild the full-text indexes by running the following MySQL queries (you can run them from MySQL command line, or via any MySQL management tool like phpMyAdmin or HeidiSQL).

USE kmp_database;
REPAIR TABLE search_index QUICK;

Be sure to use the real name for the database you're using for KMP instead of "kmp_database". Also, if you're using table prefix, you need to specify it in the table name, e.g.: prefix_search_index.


Please note that each ft_min_word_len=3 setting must go to its section. So you need to find the [mysqld] section in my.ini and insert the ft_min_word_len=3 there. Then you search for the [myisamchk] section and add ft_min_word_len=3 to it. If section doesn't exist, you can create it.