skillfed

sqlite-fts4

Python functions for working with SQLite FTS4 search

sqlite-fts4 v1.0.3 1.3M downloads/30d#4,119 on PyPI23
Permissive license Apache License, Version 2.0 Abandoned released

What it is and what it does

sqlite-fts4 is a Python module that registers custom SQL functions into SQLite to improve full-text search ranking and analysis. It provides four main functions: rank_score() implements a simple TF-IDF-based ranking, rank_bm25() implements the Okapi BM25 algorithm for relevance scoring, decode_matchinfo() converts SQLite's binary matchinfo output into human-readable JSON integers, and annotate_matchinfo() produces a verbose JSON structure explaining what each value in matchinfo means.

You use it by importing the module, calling register_functions() on a SQLite connection, and then invoking the functions in your FTS4 queries via SQL. It has no runtime dependencies and installs as a pure Python wheel, making it lightweight to add to projects that already use SQLite and FTS4 for search. The package is designed for developers building search features on top of SQLite's full-text indexing.

Use it for:

  • Rank full-text search results by relevance using BM25 scoring in a SQLite-backed application.
  • Convert opaque SQLite matchinfo binary output into readable JSON for debugging or analysis.
  • Implement TF-IDF-based document ranking without external search infrastructure.
  • Annotate matchinfo results to understand how SQLite calculated match statistics for each query.
  • Integrate search ranking into Datasette via the datasette-sqlite-fts4 plugin.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Registers custom SQLite functions for ranking and analyzing FTS4 full-text search results, including BM25 scoring, TF-IDF ranking, and matchinfo decoding.

Yes, if you are already using SQLite FTS4 and need ranking functions—it is lightweight, dependency-free, and permissively licensed. However, the package is abandoned (last update 2022-07-30) and has no active maintenance, so expect no updates for bugs or compatibility issues with future Python versions. Suitable for stable, self-contained projects; risky for long-term production systems requiring ongoing support.

Install

sqlite-fts4 on PyPI

pip

pip install sqlite-fts4

uv

uv add sqlite-fts4

poetry

poetry add sqlite-fts4

Installing sqlite-fts4

Before you install

Installation is straightforward with no runtime dependencies. The package has not been updated since 2022-07-30 and is marked abandoned, so expect no active maintenance or bug fixes.

License in practice

Licensed under Apache License 2.0 (permissive), allowing use in commercial and proprietary projects with minimal restrictions.

Quickstart

import sqlite3
from sqlite_fts4 import register_functions

conn = sqlite3.connect(":memory:")
register_functions(conn)
# Now use rank_bm25(), rank_score(), decode_matchinfo(), or annotate_matchinfo() in SQL queries

Requires an existing SQLite FTS4 table; the functions are SQL-side and work only with FTS4 indexed columns.

Verify before relying

  • Whether the package works correctly with current Python versions (support unspecified in metadata).
  • Whether the BM25 implementation matches current Okapi BM25 specifications or has known deviations.
  • Performance characteristics when used with large FTS4 indexes.

Package facts

License Apache License, Version 2.0 (permissive)
Python support not specified
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance abandoned — 1,476 days since the last release
Last repo commit
First released
Downloads 1,278,961/month — #4,119 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: sqlite_fts4-1.0.3-py3-none-any.whl

Tags

sqlite fts4 ranking functionsfull-text search scoringbm25 sqlitefts4 relevance rankingmatchinfo decodersearch result rankingsqlite search functions
search-rankingsqlite-extensionfts4

More Database packages