pub async fn keyword_search(
conn: &Connection,
query: &str,
top_k: usize,
as_of_valid: Option<&str>,
half_life: Option<Duration>,
) -> Result<Vec<(String, f64)>>Expand description
Keyword search over concept text, best match first (§5.9).
Ranked by bm25, which FTS5 returns as a negative number whose magnitude
grows with relevance, so ascending order is best-first. Retired concepts are
excluded: a soft-deleted concept is not a search result, and the index cannot
filter on retired itself because external-content FTS5 indexes only the
columns it was declared over.
The visibility predicate is the vector arm’s, spliced rather than
repeated (0.13.19, W9.4,
D-192). This
function carried its own AND c.retired = 0 from the day it was written,
and W9.3 wrote the shared constant without folding this copy into it. Two
literals that must agree is D-030’s
failure class, and W9.4 is the release that would have made them disagree:
adding the valid-time bound to one and not the other is F-31 again with a
different column.
as_of_valid bounds each hit against its own valid interval. Absent, the
statement is what 0.13.18 issued. FTS5 is not consulted about it either way:
the MATCH selects on text and the bound is applied to the joined concepts
row, which is the only place either fact lives.
The join names c.rowid_pk rather than c.rowid (v8, D-119). They are the
same value — an INTEGER PRIMARY KEY is the rowid — but concepts_fts
declares content_rowid='rowid_pk', and the join should say which key it is
joining on rather than rely on the alias holding.