SQL helpers for DuckDB's full-text search extension.
These helpers return iodata for DuckDB FTS statements and expressions. DuckDB
autoloads the fts extension on first use in many configurations, but you can
install/load it explicitly:
alias QuackDB.FTS
QuackDB.query!(conn, FTS.install())
QuackDB.query!(conn, FTS.load())
QuackDB.query!(conn, FTS.create_index("documents", :id, [:title, :body]))
score = FTS.match_bm25(~s|"id"|, "duckdb analytics", schema: FTS.schema_name("main.documents"))
QuackDB.query!(conn, ["SELECT id, ", score, " AS score FROM documents ORDER BY score DESC"])bm25/3 and search_score/3 are aliases for match_bm25/3. Use stem/2
for DuckDB's stemming helper.
Summary
Functions
Builds PRAGMA create_fts_index(...).
Builds PRAGMA drop_fts_index(...).
Builds an INSTALL fts; statement.
Builds a LOAD fts; statement.
Builds match_bm25(id, query, ...).
Returns DuckDB's generated FTS schema name for a table.
Alias for match_bm25/3 when using the expression as a score/rank.
Builds stem(text, stemmer).
Types
Functions
@spec bm25(iodata(), String.t(), [match_option()]) :: iodata()
Alias for match_bm25/3.
@spec create_index( atom() | String.t(), atom() | String.t(), [atom() | String.t()] | :all, [ create_option() ] ) :: iodata()
Builds PRAGMA create_fts_index(...).
Builds PRAGMA drop_fts_index(...).
@spec install() :: iodata()
Builds an INSTALL fts; statement.
@spec load() :: iodata()
Builds a LOAD fts; statement.
@spec match_bm25(iodata(), String.t(), [match_option()]) :: iodata()
Builds match_bm25(id, query, ...).
Returns DuckDB's generated FTS schema name for a table.
@spec search_score(iodata(), String.t(), [match_option()]) :: iodata()
Alias for match_bm25/3 when using the expression as a score/rank.
Builds stem(text, stemmer).