sqlite-fts4 is a Python library providing custom SQLite functions designed for efficient full-text search (FTS4) ranking and decoding. It offers functions like `rank_score`, `rank_bm25`, `decode_matchinfo`, and `annotate_matchinfo` to enhance the utility of SQLite's built-in FTS4 extension. The library, currently at version 1.0.3, is actively maintained with a focus on stability and compatibility, addressing specific issues such as big-endian system support.
pip install sqlite-fts4Verified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to establish an SQLite connection, register the `sqlite-fts4` custom functions, create an FTS4 virtual table, insert data, and then perform a full-text search with relevance ranking using `rank_score`.
Always pass the exact required `matchinfo` format string (e.g., `matchinfo(table, 'pcx')`) to `rank_score()` or `rank_bm25()`.
Sanitize user input for FTS queries, consider disabling advanced FTS operators for untrusted input, or implement a custom parser to build safe FTS queries from user-friendly input.
Ensure `MATCH` clauses are always present when `matchinfo()` is intended to be used with meaningful data, or explicitly handle the silently failing case for empty `matchinfo` buffers.
If encountering this error, ensure your Python installation uses an SQLite library compiled with FTS4. This may involve installing Python/SQLite from source or using a distribution that provides FTS4-enabled `sqlite3`.
Ensure the extension is loaded using `conn.load_extension(sqlite_fts4.loadable_path())` on the `sqlite3.Connection` object after importing `sqlite_fts4`.
Install the library using pip: `pip install sqlite-fts4`.
The functions are exposed directly within SQL queries after loading the extension. Simply import `sqlite_fts4` to get the loadable path, then load it into your SQLite connection: `import sqlite_fts4; conn.load_extension(sqlite_fts4.loadable_path())`.
Verify that `sqlite_fts4.loadable_path()` returns a valid and accessible path. Check file permissions for the extension file and its containing directory, and ensure the `sqlite-fts4` package was installed correctly.
No dependency data recorded yet.