Help:Short words in searches

From Meta, a Wikimedia project coordination wiki
Jump to: navigation, search

Changing minimum and maximum word lengths in MySQL[edit]

Option 1[edit]

From MySQL's docs on Fine-Tuning MySQL Full-Text Search:

The minimum and maximum length of words to be indexed is defined by the ft_min_word_len and ft_max_word_len system variables (available as of MySQL 4.0.0). See Section 5.3.3, “Server System Variables”. The default minimum value is four characters. The default maximum depends on your version of MySQL. If you change either value, you must rebuild your FULLTEXT indexes. For example, if you want three-character words to be searchable, you can set the ft_min_word_len variable by putting the following lines in an option file (you can simply put these lines in my.cnf (usually /etc/my.cnf):

[mysqld]
ft_min_word_len=3
[myisamchk]
ft_min_word_len=3

Then restart the server in the appropriate way for your OS and rebuild your FULLTEXT indexes. Also note particularly the remarks regarding myisamchk in the instructions following this list.

php rebuildtextindex.php
  • Also, go to LocalSettings.php and make sure mediawiki is correctly set up for mysql4 (If you are running mysql 4!!!)! See these lines:
# If you're on MySQL 3.x, this next line must be FALSE:
$wgDBmysql4 = $wgEnablePersistentLC = true;

You might want to consult Fine-Tuning MySQL Full-Text Search for further reference.

Option 2[edit]

I could not get the above to work (Windows XP SP2, SQL5.0, PHP5) but found following very simple and effective:

1 Find the my.ini file in the SQL install folder (eg C:\Program Files\MySQL\MySQL Server 5.0) and add in the lines

[mysqld]
ft_min_word_len=3

[myisamchk]
ft_min_word_len=3

under

[mysql]
default-character-set=latin1

in the Client Section

2 Using MySQL Admin stop and restart the service
3 Using MySQL Admin select catalogs, wikidb, and then the schema table 'searchindex'. Click on maintenance and run a Quick Repair on the table.

See also[edit]