Section: Search, rank, and highlight

Rank results with bm25()

sql
sql
SELECT rowid, title, bm25(docs) AS rank
FROM docs
WHERE docs MATCH 'sqlite wal'
ORDER BY rank;
Explanation

bm25() is the usual relevance-ranking helper for FTS5 results.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Search, rank, and highlight
Search with MATCH
Find rows containing a term.
OpenIn sheetsqlsame section
Run a phrase search
Search for words appearing together in order.
OpenIn sheetsqlsame section
Run a prefix search
Match terms by prefix.
OpenIn sheetsqlsame section
Highlight matches or return snippets
Decorate matched terms in search output.
OpenIn sheetsqlsame section
Create an FTS5 virtual table
Store searchable text in an FTS5 index.
OpenIn sheetsql1 tag match
Insert searchable content
Add rows to an FTS5 table.
OpenIn sheetsql1 tag match