Fulltext Search with InnoDB
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
InnoDB supports full-text indexing so MySQL can search large text columns more intelligently than simple LIKE scans. The feature is useful for natural-language style queries, but it works best when you understand its indexing rules, search modes, and limitations around stopwords and token size.
Creating a Full-Text Index
You can create a full-text index on CHAR, VARCHAR, or TEXT columns.
Once the index exists, MySQL can evaluate MATCH ... AGAINST queries efficiently.
Natural Language Search
The default search mode is natural language mode:
This returns rows ranked by relevance. Unlike LIKE '%database%', the full-text engine tokenizes and scores results instead of scanning blindly for a substring.
Boolean Mode
Boolean mode gives you more control over required terms, excluded terms, and optional weighting.
In this example:
- '
+mysqlmeans the term must appear' - '
-oraclemeans the term must not appear' - '
+indexalso must appear'
Boolean mode is useful when you want search syntax closer to query operators than to pure relevance ranking.
Loading Sample Data
Now you can run:
This is the simplest end-to-end example: create the index, load rows, and query with MATCH ... AGAINST.
Stopwords and Minimum Token Length
Two settings affect what gets indexed:
- stopwords
- minimum token size
Common words may be ignored entirely, and very short terms may not be indexed depending on server settings. With InnoDB, token-size configuration affects whether short terms such as abbreviations or two-letter words can be searched meaningfully.
This explains many "why did my term return nothing?" questions. The row may exist, but the term was never indexed in the first place.
When Full-Text Search Is a Good Fit
InnoDB full-text search is useful when:
- search lives inside MySQL already
- the corpus is moderate in size
- you want relevance ranking without introducing a separate search engine
It is less suitable when you need sophisticated linguistic analysis, typo tolerance, synonyms, highlighting, or large-scale search features. At that point, dedicated search systems may be a better fit.
Common Pitfalls
The most common mistake is expecting MATCH ... AGAINST to behave exactly like LIKE. Full-text search works on indexed tokens and relevance, not arbitrary substrings.
Another issue is forgetting to create a full-text index before benchmarking. Without the index, you do not get the intended search behavior or performance.
A third pitfall is ignoring stopwords and token-size rules. If short words or common words are important to your application, default indexing rules may not match your expectations.
Finally, do not assume relevance ordering is business ordering. Full-text score is useful, but many applications still combine it with publish date, category filters, or custom ranking logic.
Summary
- InnoDB full-text search uses
FULLTEXTindexes andMATCH ... AGAINSTqueries. - Natural language mode ranks results by relevance.
- Boolean mode gives explicit control over required and excluded terms.
- Stopwords and token-size settings affect what can be searched.
- Full-text search is powerful inside MySQL, but it is not a full replacement for a dedicated search engine in every case.

