Full-Text Search (FTS)Intermediate
1Question 1 of 1
sqlHow does Full-Text Search (FTS5) work in SQLite?
Explanation & Concept
SQLite includes the **FTS5** virtual table module, implementing an inverted index for fast full-text searching, tokenization, BM25 relevance ranking, and highlighted snippets.
Code Example
sql
-- Create FTS5 virtual table
CREATE VIRTUAL TABLE documents_fts USING fts5(title, body);
-- Insert content
INSERT INTO documents_fts (title, body)
VALUES ('SQLite Performance', 'WAL mode and index coverage improve database speed dramatically.');
-- Search with BM25 ranking and highlighted snippet
SELECT
title,
snippet(documents_fts, 1, '<b>', '</b>', '...', 15) AS preview,
bm25(documents_fts) AS rank
FROM documents_fts
WHERE documents_fts MATCH 'speed OR performance'
ORDER BY rank;How It Works & Key Takeaways
FTS5 indexes token stems and matches complex boolean queries with sub-millisecond execution times without external full-text search software.
Mock Test · 1 Questions · Optional
Ready for Triggers?
Take a quick test to evaluate yourself, or move straight to the next module.
Advanced1 questions