MySQL support text search with the help of LIKE operator and Regular expressions. However, it is not a full-fledged text search as it does not provide relevant ranking of search results, results for complex queries and is not performance oriented.
To overcome these limitations, MySQL has come up with a new feature called full-text search. It is available only for InnoDb and MyISAM engines after version 5.6. Full-text search uses a sophisticated algorithm to eliminate drawbacks.
It has the following features:
How to use it:
Example:
ALTER TABLE table_name ADD FULLTEXT(column_name1, column_name2,…)
Example
For searching ‘Classic’ keyword in productline column (this column should be FULLTEXT Indexed)
SELECT productName, productline FROM products WHERE MATCH(productline) AGAINST('Classic')
For searching ‘Classic’ AND/OR VINTAGE keyword in productline column (rows with both keywords will have a higher rank)
SELECT productName, productline FROM products WHERE MATCH(productline) AGAINST('Classic,Vintage').
It’s as simple as that! MySQL full-text search is a really cool and simple feature to use.
Reference: http://www.mysqltutorial.org/introduction-to-mysql-full-text-search.aspx
(Photo: Wikimedia)