MySQL:“布尔模式”下的意外行为

发布于 2024-08-22 01:16:30 字数 676 浏览 6 评论 0原文

我使用以下调用从数据库获取信息:

select * 
from submissions 
where 
   match( description ) against ('+snowboard' in boolean mode ) 
   and (!disabled or disabled='n') 
order by datelisted desc limit 30

这意味着找到了描述中带有“snowboard”的所有内容。现在的问题是:

select *
from submissions 
where 
  match( description ) against ('+snowboard +mp4' in boolean mode ) 
  and (!disabled or disabled='n') 
order by datelisted desc limit 30

由于某种原因将忽略 +mp4 并返回与第一个查询相同的内容,

select * 
from submissions 
where 
   match( description ) against ('+mp4' in boolean mode ) 

不会返回任何内容,因此基本上它似乎在搜索中被忽略

有人知道如何解决此行为吗?

I use the following call for getting information from a database:

select * 
from submissions 
where 
   match( description ) against ('+snowboard' in boolean mode ) 
   and (!disabled or disabled='n') 
order by datelisted desc limit 30

Which means everything with ‘snowboard' in the description is found. Now here’s the problem:

select *
from submissions 
where 
  match( description ) against ('+snowboard +mp4' in boolean mode ) 
  and (!disabled or disabled='n') 
order by datelisted desc limit 30

will ignore the +mp4 for some reason and return the same as the first query

select * 
from submissions 
where 
   match( description ) against ('+mp4' in boolean mode ) 

doesn't return anything, so basically it appears it's ignored in the search

Does anybody know how to work around this behavior?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

唯憾梦倾城 2024-08-29 01:16:30

mysql的布尔模式只会匹配超过一定长度的单词。并且 mp4 太短。你必须重新编译mysql来更改阈值

编辑:事实证明,现在可以通过配置文件设置,请参阅http://dev.mysql.com/doc/refman/5.0/en/fulltext-fine-tuning.html 供进一步参考

mysql's boolean mode will only match words which are longer than a certain length. and mp4 is too short. you'd have to recompile mysql to change the threshold

EDIT: turns out, this can now be set via the config file, see http://dev.mysql.com/doc/refman/5.0/en/fulltext-fine-tuning.html for furhter reference

夜未央樱花落 2024-08-29 01:16:30

您的问题是最小字长,默认情况下为 3 个字符。
尝试使用 +snowboard +scooter 进行相同的操作,您会发现它有效。 (当然,假设您的数据库中没有踏板车)。

请参阅微调 MySQL 全文搜索关于如何更改它:

要索引的单词的最小和最大长度由 ft_min_word_lenft_max_word_len 系统变量定义。 (请参见第 5.1.4 节“服务器系统变量”。)默认最小值为四个字符;默认最大值取决于版本。如果更改任一值,则必须重建 FULLTEXT 索引。例如,如果您希望可搜索三个字符的单词,则可以通过将以下行放入选项文件中来设置 ft_min_word_len 变量:

<代码>[mysqld]
ft_min_word_len=3

然后重新启动服务器并重建全文索引。请特别注意此列表后面的说明中有关 myisamchk 的注释。

Your problem is the minimum word length, which by default is 3 characters.
Try the same with +snowboard +scooter and you will see that it works. (Supposing you don't have scooters in your database, of course).

See Fine-Tuning MySQL Full-Text Search on how to change it:

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. (See Section 5.1.4, “Server System Variables”.) The default minimum value is four characters; the default maximum is version dependent. If you change either value, you must rebuild your FULLTEXT indexes. For example, if you want three-character words to be searchable, you can set the ft_min_word_len variable by putting the following lines in an option file:

[mysqld]
ft_min_word_len=3

Then restart the server and rebuild your FULLTEXT indexes. Note particularly the remarks regarding myisamchk in the instructions following this list.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文