The minimum length for words to be
included in FULLTEXT indexes is established by the ft_min_word_len server variable.
For example, if you want three-character words to be searchable, all you have to do is to set the
ft_min_word_len variable in your MySQL server configuration file like this:
[mysqld]
ft_min_word_len=3
The configuration file where you should store this setting is usually /opt/lampp/etc/my.cnf in Unix
and C:\xampp\mysql\bin\my.cnf or C:\Windows\php.ini in Windows. You can find detailed instructions
on how to modify this value and perform other FULLTEXT fine-tuning operations in the article at
http://dev.mysql.com/doc/refman/5.0/en/fulltext-fine-tuning.html.
After changing the value of ft_min_word_len, you must restart your MySQL server. After restarting
the server, you can query your MySQL server for the values of your variables to make sure the changes have
taken effect using a query such as
SHOW VARIABLES LIKE 'ft_%';
After changing the value of ft_min_word_len, you must rebuild your FULLTEXT indexes as well. You
can do this by either dropping and re-creating the index or using REPAIR TABLE like this:
REPAIR TABLE product QUICK;
Note that you only need to REPAIR the tables on which you have FULLTEXT indexes. If, for some
reason, you prefer to re-create the index (we advise using REPAIR TABLE though), you can do so like this:
ALTER TABLE product
DROP INDEX idx_ft_product_name_description;
CREATE FULLTEXT INDEX idx_ft_product_name_description
ON product (name, description);
Teaching MySQL to Do All-Words Searches
We??™ve already seen that an any-words search will return all the products that contain ???flower or
???beautiful??? (or both words) in their names or descriptions.
Pages:
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340