sqlite-fts4
Python functions for working with SQLite FTS4 search
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-fts4uv
uv add sqlite-fts4poetry
poetry add sqlite-fts4Installing 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
More Database packages
psycopg2-binary is a PostgreSQL database…
copyleft · top 1,000 on PyPI
redisPython client library for connecting to and…
permissive · top 1,000 on PyPI
ydbYDB Python SDK is the official client library…
permissive · top 1,000 on PyPI
snowflake-connector-pythonConnects Python applications to Snowflake data…
permissive · top 1,000 on PyPI
sqlparsesqlparse tokenizes SQL text into a tree of…
permissive · top 1,000 on PyPI
dbt-adaptersProvides base adapter protocols and shared…
permissive · top 1,000 on PyPI
rank-bm25Implements BM25 ranking algorithms (Okapi BM25,…
permissive · top 5,000 on PyPI
bm25sBM25S implements the BM25 ranking algorithm in…
permissive · top 5,000 on PyPI
sqlite-utilsCLI tool and Python library for creating,…
permissive · top 5,000 on PyPI
sqlean.pyA drop-in replacement for Python's sqlite3…
permissive · top 5,000 on PyPI
llama-index-retrievers-bm25Integrates BM25 full-text search retrieval into…
permissive · top 15,000 on PyPI
syntaqliteParse, format, validate, and tokenize SQLite…
permissive · top 15,000 on PyPI
apache-airflow-providers-sqliteIntegrates SQLite databases with Apache Airflow…
permissive · top 5,000 on PyPI
FlashRankFlashRank re-ranks search results using…
permissive · top 15,000 on PyPI
anysqliteAnysqlite wraps SQLite with an async/await…
unclear · top 5,000 on PyPI
pysqlite3pysqlite3 packages SQLite as a standalone…
permissive · top 15,000 on PyPI