duanbu1998 2010-02-09 09:00
浏览 999
已采纳

MySQL匹配 - IN BOOLEAN MODE?

I'm using PDO to execute a MATCH AGAINST query.

The following returns nothing:

SELECT title, author, isbn, MATCH(title, isbn) AGAINST (:term) AS score 
FROM books 
WHERE MATCH(title, isbn) AGAINST (:term)
ORDER BY score DESC LIMIT 0,10

Where as this returns perfectly:

SELECT title, author, isbn, MATCH(title, isbn) AGAINST (:term) AS score
FROM books
WHERE MATCH(title, isbn) AGAINST (:term IN BOOLEAN MODE)
ORDER BY score DESC LIMIT 0,10

Could anyone tell me why IN BOOLEAN MODE is making such a difference, and whether or not I should be using it in my query?

  • 写回答

1条回答 默认 最新

  • doujiang6944 2010-02-09 14:43
    关注

    The second query is running as a "natural language search" as that is the default when no natural language search type is specified. This type of search filters additionally filters out words that are present in 50% or more of the rows automatically.

    "IN BOOLEAN MODE" does do this additional filtering, and thus, may return matches if you are searching on a common term.

    Whether or not you should be using a boolean search depends on what the specifics of your situation and cannot be determined without more information. However, some considerations may include, size of the input data set vs how large of a matching dataset you want returned and whether you want to return results for words that occur frequently.

    (Ref: http://dev.mysql.com/doc/refman/5.1/en/fulltext-search.html)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘