MySQL Fulltext searching and minimum search term length

妖精的绣舞 提交于 2019-12-10 11:24:54

问题


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.



来源:https://stackoverflow.com/questions/3239962/mysql-fulltext-searching-and-minimum-search-term-length

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!