Spec-Zone .ru
спецификации, руководства, описания, API

12.9.2. Boolean Full-Text Searches

MySQL can perform boolean full-text searches using the IN BOOLEAN MODE modifier. With this modifier, certain characters have special meaning at the beginning or end of words in the search string. In the following query, the + and - operators indicate that a word must be present or absent, respectively, for a match to occur. Thus, the query retrieves all the rows that contain the word "MySQL" but that do not contain the word "YourSQL":

mysql> SELECT * FROM articles WHERE MATCH
        (title,body)    AGAINST ('+MySQL -YourSQL' IN BOOLEAN
        MODE);+----+-----------------------+-------------------------------------+| id | title                 | body                                |+----+-----------------------+-------------------------------------+|  1 | MySQL Tutorial        | DBMS stands for DataBase ...        ||  2 | How To Use MySQL Well | After you went through a ...        ||  3 | Optimizing MySQL      | In this tutorial we will show ...   ||  4 | 1001 MySQL Tricks     | 1. Never run mysqld as root. 2. ... ||  6 | MySQL Security        | When configured properly, MySQL ... |+----+-----------------------+-------------------------------------+
Note

In implementing this feature, MySQL uses what is sometimes referred to as implied Boolean logic, in which

  • + stands for AND

  • - stands for NOT

  • [no operator] implies OR

Boolean full-text searches have these characteristics:

The boolean full-text search capability supports the following operators:

The following examples demonstrate some search strings that use boolean full-text operators: