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 安装svn网络有问题怎么办
  • ¥15 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 latex怎么处理论文引理引用参考文献