MySQL全文停用词问题
我有一个名为“products”的数据库和一个包含以下列的 FULLTEXT 索引:title
和 description
。我所有的产品都是润滑油(油),有工业用和汽车用两种,比例在55%-45%。 如果我在 auto-moto 油之后进行搜索,那么它将不会返回任何结果,因为“auto-moto”关键字出现在超过一半的行中,并且所有行中都存在油,因此 MySQL 将它们放入停用词中列表。
我正在使用 PHP。我怎样才能使该查询返回正确的结果?
I have a database named "products" and a FULLTEXT index with the columns: title
and description
. All of my products are lubrifiants (oils), and there are two types of it: industrials and aut-moto, with a rate of 55%-45%.
If I make a search after auto-moto oils then it will return no results because the "auto-moto" keyword is present in more then half of the rows, and the oils in all of them, so the MySQL puts them into the STOPWORDS list.
I am using PHP. How can I make that query to give back the right results?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
答案是
IN BOOLEAN MODE
。如果您使用布尔模式,那么 mysql 将忽略该键出现在超过 50% 的行中。同时它还有一个非常强大且有用的能力:AGAINST ('*key*')
。The answer is
IN BOOLEAN MODE
. If you use boolean mode then the mysql will ignore that the key is present in more then 50% of the rows. In the same time it has a very strong and useful ability:AGAINST ('*key*')
.难道是因为 auto-moto 包含一个“-”字符,根据
http://dev.mysql.com/doc/refman/5.0 /en/fulltext-boolean.html 执行 NOT 搜索,
所以所有带有“auto”但不是“moto”的行
尝试搜索“auto moto”
你也可以发布你正在使用的实际SQL,可能有助于诊断问题
Could it be because auto-moto contains a "-" character which according to
http://dev.mysql.com/doc/refman/5.0/en/fulltext-boolean.html performs a NOT search,
so all rows with "auto" but NOT "moto"
try searching for "auto moto"
also could you post the actual SQL you are using, might help in diagnosing the problem