liveBook · Manning

Full-text search index

As explained in Grokking Relational Database Design

A full-text index is a specialized database index that supports efficient searching within larger text values.

A full-text index is a specialized database index for searching within large text values. It makes keyword searches practical instead of requiring a slow linear scan of every text value. section 4.5 section 7.9

Use a full-text index when the requirement is keyword search rather than exact matching:

  • Identify a text-search interaction, such as users searching for products by name. section 7.10
  • Create the full-text index on the searched column. section 7.10
  • Search with MATCH and AGAINST in MySQL or MariaDB. section 7.10
  • Use a standard index for exact matches, such as a product code or email address. section 7.10

Searching product names

For a product table, create a full-text index on name, then search for matching words such as “some text.” A LIKE search over a large text column can be replaced by a full-text search. section 7.10 section 7.9

-- comment: works for MySQL and MariaDB
-- comment: consult ChatGPT on adaptations
-- comment: for other RDBMS
CREATE FULLTEXT INDEX ft_idx_name ON product (name);

Shows the SQL statement for creating a full-text index on product.name. section 7.10

-- comment: works with MySQL and MariaDB
-- comment: consult ChatGPT on adaptations 
-- comment: for other RDBMS
SELECT * FROM product WHERE MATCH (name)
 AGAINST ('some text' IN NATURAL LANGUAGE MODE);

Shows the corresponding MATCH ... AGAINST keyword query in natural-language mode. section 7.10

How Grokking Relational Database Design covers it

How deep it goes
Defines the purpose and SQL workflow, but does not explain the internal search structure or ranking algorithm.
Examples
Uses product-name keyword searches, movie-title searches, and exact-match contrasts with review codes and payment-method emails.
What it assumes
Introduces indexing alongside standard indexes and distinguishes keyword searches from exact-match queries.
What you can do after
Apply it via SQL by creating a full-text index and querying indexed text with MATCH and AGAINST.
How it connects
Connects full-text indexes with database indexes, standard indexes, SQL queries, text data types, and query performance.

Also explained in

Compare how 3 books explain full-text search index →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Relational Database Design. The section links point to the parts of the book it draws on.