Search⌘ K
AI Features

Full-Text Search

Understand how to implement full-text search in MySQL by creating FULLTEXT indexes and performing natural language, boolean, and query expansion searches. Learn to improve text matching and relevance ranking for complex search queries using MySQL's advanced string functions.

MySQL provides capabilities for matching regular expressions against some text. For example, using REGEXP_LIKE(), we can match the regular expression (ex|in)terior against the names of car parts as in our running example:

MySQL
-- Retrieve all exterior and interior car parts.
SELECT *
FROM CarPart
WHERE REGEXP_LIKE(name, '(ex|in)terior');

However, pattern matching only unfolds its full potential if applied to longer texts. One of the functions provided by MySQL, REGEXP_SUBSTR(), is particularly useful in this case. The function returns the nthn^{th} match of a regular expression in the specified text. While this concept is powerful, it is limited by the strictness of the regular expression syntax. That is, we cannot perform actual fuzzy matching, i.e., searching for matches that are not exact but ...