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 | MariaDB Tutorial | DBMS stands for DataBase ... |
| 2 | How To Use MariaDB Well | After you went through a ... |
| 3 | Optimizing MariaDB | In this tutorial we will show ... |
| 4 | 1001 MariaDB Tricks | 1. Never run mysqld as root. 2. ... |
| 6 | MariaDB Security | When configured properly, MariaDB ... |
+----+-----------------------+-------------------------------------+
Note

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

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:

Retornar