Full Text Searching is a method of searching data.
In MySQL,  Full Text Searching literally allows us to search for a needle in a haystack in no time !

In order to use this feature, a full text index has to exist on a the given column. In MySQL, this type of index is only permitted on MyISAM tables (expected to change in further versions).

There are 3 modes of FT Searching :

1. Natural Language Search (Default) :


The following query searches for the word ‘database’ in the columns ‘title’ or ‘body’
eg :
SELECT * FROM articles WHERE MATCH (title,body)    AGAINST (‘database’ );

2.  Boolean Search :


Boolean mode allows us to use complex expressions which can state whether data should contain certain words,whether data shouldn’t contain certain words,whether data should contain a certain phrase etc.

The following query searches for data having the word ‘mysql’ AND
not having the word ‘yoursql’
eg :
SELECT * FROM articles WHERE MATCH (title,body)

The following table shows the different types of operators permitted :

Example Action
‘apple banana’ Find rows that contain at least one of the two words.
‘+apple +juice’ Find rows that contain both words.
‘+apple macintosh’ Find rows that contain the word “apple”, but rank rows higher if they also contain “macintosh”.
‘+apple -macintosh’ Find rows that contain the word “apple” but not “macintosh”.
‘+apple ~macintosh’ Find rows that contain the word “apple”, but if the row also contains the word “macintosh”, rate it lower than if row does not. This is “softer” than a search for ‘+apple -macintosh’, for which the presence of “macintosh” causes the row not to be returned at all.
‘+apple +(>turnover <strudel)’ Find rows that contain the words “apple” and “turnover”, or “apple” and “strudel” (in any order), but rank “apple turnover” higher than “apple strudel”.
‘apple*’ Find rows that contain words such as “apple”, “apples”, “applesauce”, or “applet”.
‘”some words”‘ Find rows that contain the exact phrase “some words” (for example, rows that contain “some words of wisdom” but not “some noise words”). Note that the “”” characters that enclose the phrase are operator characters that delimit the phrase. They are not the quotes that enclose the search string itself.


Some Rules of Boolean Search :

  • Zero rows are returned if word searched is less than the minimum word length defined in the variable ft_min_word_len in the cnf file of MySQL (default is 4 letters).
  • 50% threshold rule  doesnt apply here.
  • The stopword list applies. It contains common words (like ‘in’,’of’ etc) which are ignored while searching.

3. Query Expansion :


This is for the user who relies on implied knowledge to get the desired result. For example, a user searching for “database” may really mean that “MySQL”, “Oracle”, “DB2”, and “RDBMS” all are phrases that should match “databases” and should be returned, too. This is implied knowledge.
eg :
SELECT * FROM articles WHERE MATCH (title,body)

Ref :
MySQL – Full Text Boolean Search
MySQL – FT Search with Query Expansion
FT Searching Slideshow
New Features in FT Searching Slideshow
Preetul – How to Change the full text index minimum word length

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s