MySQL:“布尔模式”下的意外行为
我使用以下调用从数据库获取信息:
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
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 thresholdEDIT: 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
您的问题是最小字长,默认情况下为 3 个字符。
尝试使用
+snowboard +scooter
进行相同的操作,您会发现它有效。 (当然,假设您的数据库中没有踏板车)。请参阅微调 MySQL 全文搜索关于如何更改它:
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: