MySQL Fulltext searching and minimum search term l

2019-05-21 10:07发布

问题:

I am using fulltext searching in mysql to search a database of videos I have, however when I search my videos some results will never get returned because the title I am searching for is less than the ft_min_word_len set in MySQL's settings.

mysql_query("SELECT MATCH(videoDescription) AGAINST('".$searchString."' IN NATURAL LANGUAGE MODE) 
               FROM videos 
              LIMIT ".$start.",".$end."");

I tried firing up the mysql console to change the setting, however it told me it is read only. The only possible solution I have seen is to have the setting overridden at startup with option files. How do I use option files to overwrite the ft_min_word_len to 2 at startup?

回答1:

ft_min_word_len is a system variable, that has to be set at the startup of the MySQL server.

This can be done passing parameters on the command-line used to start MySQL, or (recommended, I'd say), using a file containing options -- generally, for example, something like /etc/my.cnf or /etc/mysql/my.cnf should do the trick.


For more informations about setting system variables, you can take a look at the following section of the manual :

  • 4.2.3. Specifying Program Options


Also, don't forget that you'll have to rebuild your fulltext index, after changing that parameter, so the new value is taken into account.