MySQL全文搜索和最小搜索项长度 [英] MySQL Fulltext searching and minimum search term length

查看:117
本文介绍了MySQL全文搜索和最小搜索项长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在mysql中使用全文搜索来搜索我有的视频数据库,但是当我搜索我的视频时,一些结果永远不会返回,因为我搜索的标题比在MySQL设置中设置的ft_min_word_len少。

$ p $ mysql $查询(SELECT MATCH(videoDescription)AGAINST('。$ searchString。'在自然语言模式下)
FROM视频
LIMIT。$ start。,。$ end。);

我尝试启动mysql控制台来更改设置,但它告诉我它是只读的。我所看到的唯一可能的解决方案是使用选项文件在启动时覆盖设置。如何使用选项文件在启动时将ft_min_word_len覆盖为2?

解决方案

ft_min_word_len 是一个系统变量,必须在MySQL服务器启动时设置。



这可以通过传递参数在用于启动MySQL的命令行上,或使用包含选项的文件(推荐的,我会说),通常,例如,像 / etc / my.cnf /etc/mysql/my.cnf 应该有效。





有关设置系统变量的更多信息,请参阅手册的以下部分:





另外,不要忘记你必须重建你的全文索引,改变这个参数后,所以新的值被考虑在内。


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?

解决方案

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 :


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.

这篇关于MySQL全文搜索和最小搜索项长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆