SyntaxStudy
Sign Up
MySQL Intermediate 4 min read

Query Expansion

Query Expansion

With WITH QUERY EXPANSION, MySQL performs a second search using words from the top results of the first — broadening the result set to related topics.

Example
SELECT title
FROM articles
WHERE MATCH(title, body)
      AGAINST('database' WITH QUERY EXPANSION)
LIMIT 20;

-- MySQL first finds "database" articles,
-- then expands using words from those top results
Pro Tip

Query expansion works best on large datasets — avoid on small tables where it over-expands.