MATCH…AGAINST in Boolean mode

If you wish to give your MATCH…AGAINST queries even more power, use Boolean mode. This changes the effect of the standard FULLTEXT query so that it searches for any combination of search words, instead of requiring all search words to be in the text. The presence of a single word in a column causes the search to return the row. Boolean mode also allows you to preface search words with a + or – sign to indicate
whether they must be included or excluded. If normal Boolean mode says, “Any of these words will do,” a plus sign means, “This word must be present; otherwise, don’t return the row.” A minus sign means, “This word must not be present; its presence disqualifies the row from being returned.”

The first asks for all rows containing the word suosikkia and not the word Aro to be returned. The second uses double quotes to request that all rows containing the exact phrase origin of be returned.

SELECT author,title FROM classics
WHERE MATCH(author,title)
AGAINST(‘+suosikkia -Aro’ IN BOOLEAN MODE);
SELECT author,title FROM classics
WHERE MATCH(author,title)
AGAINST(‘kaikki parhaat’ IN BOOLEAN MODE);

Leave a Reply

Your email address will not be published. Required fields are marked *