简体   繁体   English

mysql全文搜索不适用于3个字符

[英]mysql full-text search not working for 3 characters

In my website I have implemented search feature using full-text search. 在我的网站中,我使用全文搜索实现了搜索功能。

It works fine usually but not sometimes like it gives results when I search with keyword "ship" but not "shi" 它通常工作正常但有时候不会像我用关键字“ship”而不是“shi”搜索时给出结果

But it should return. 但它应该回归。 Please help me why this happening. 请帮助我为什么会这样。

The minimum and maximum lengths of words to be indexed are defined by the ft_min_word_len and ft_max_word_len system variables. 要索引的单词的最小和最大长度由ft_min_word_lenft_max_word_len系统变量定义。 The default minimum value is 4 characters. 默认最小值为4个字符。 That is why it's not working with 3 characters. 这就是为什么它不能使用3个字符。

You need to change its value, and rebuild your FULLTEXT indexes. 您需要更改其值,并重建您的FULLTEXT索引。 If you want three-character words to be searchable, you can set the ft_min_word_len variable by changing its value in the configuration file. 如果要搜索三个字符的单词,可以通过更改配置文件中的值来设置ft_min_word_len变量。 Or, if you have super user permissions you can set this environment variable with: 或者,如果您具有超级用户权限,则可以使用以下命令设置此环境变量:

  SET  ft_min_word_len=3

Get more details here: Fine-Tuning MySQL Full-Text Search 在此处获取更多详细信息: 微调MySQL全文搜索

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM