Search
Hybrid transcript search with SQLite
Find exact quotes and paraphrases in a recording with SQLite FTS5, local embeddings, and reciprocal rank fusion. Try the example and inspect the rankings.

In this article
Use SQLite FTS5 to find the words a speaker actually said, and an embedding index to find passages that express a similar idea. Give both indexes the same passage IDs so you can combine results and return to the right timestamp in the recording.
Index timecoded passages
Searching for “raised prices” and asking why a subscription got more expensive are two different jobs. The first needs an exact phrase under the tokenizer’s rules. The second could be answered by someone saying that the old fee didn’t cover costs, with none of the query’s key words. One transcript can support both.
Store passages with an ID, recording ID, speaker, start and end times, and text. For precise lookup, index individual sentences with FTS5. For a production semantic index, try passages that hold a whole turn or a few related sentences. Keep IDs for the underlying sentences so you can align the results. The example below uses the same five passages for both indexes to make the rankings easy to inspect.
Tie both indexes to the transcript revision. If a correction changes the transcript, refresh the affected text index entries and embeddings together. Return a timestamp and the original words with each result.
Phrase and semantic search
Exact phrases with FTS5
Create an FTS5 table with the passage ID as its rowid. The query below assumes a matching passages table that holds the source metadata. For literal phrase mode, wrap the input in double quotes, double any embedded quotes, and bind it as a parameter. Binding protects the SQL statement. Quoting also keeps words such as OR from being interpreted as FTS query operators.
SELECT p.id, p.start_ms, p.end_ms, p.text
FROM passage_fts
JOIN passages AS p ON p.id = passage_fts.rowid
WHERE passage_fts MATCH ?
ORDER BY bm25(passage_fts), p.id
LIMIT ?;FTS5’s bm25() uses ascending order, with better matches receiving numerically lower scores. Phrase matching operates on tokens, so casing and punctuation may differ from the typed phrase. Apply any recording or time filter before limiting results. SQLite FTS5 reference.
Matching by meaning
Embed the passages once and the query once per search. This example uses multilingual E5 small in ONNX. Prefix the indexed strings with passage: and the search terms with query:, with a space after each prefix. Mask padding during mean pooling, then normalize the vectors so their dot product equals cosine similarity. Start by comparing every vector in the chosen recording. Measure latency on your data before adding an approximate index. Multilingual E5 model card.
Worked example
We ran both searches on five fictional passages. Select the paraphrase to see exact phrase search return zero results and meaning search place the passage about subscription costs first at 23:16.
Compare the rankings
- 08:12The supplier raised prices twice before we changed packaging.
- 12:48We raised prices in May after switching to weekly deliveries.
Rankings from a local run on five fictional passages.
Switch back to “raised prices.” Both the supplier and the interviewee said those words. The meaning search ranks the interviewee first. Combining the two lists produces a tie between those passages, resolved in this example by passage ID. A speaker filter would help answer whose price changed.
To reproduce the example, use Python with SQLite FTS5, NumPy, ONNX Runtime, and Tokenizers. Pass a multilingual E5 small model directory with tokenizer.json and onnx/model_quantized.onnx. The script prints the fixture and all three rankings. Download the example script.
Combine ranks
The raw scores on the two lists live on different scales. Reciprocal rank fusion adds a contribution based on each passage’s position in each list. At rank r, that contribution is 1 / (k + r), with ranks starting at one and absent passages contributing zero. The original RRF study used k = 60. Treat candidate depth and k as settings to check on your own queries. Cormack, Clarke, and Büttcher, SIGIR 2009.
from collections import defaultdict
def fuse(*rankings, k=60):
scores = defaultdict(float)
for ranking in rankings:
for rank, passage_id in enumerate(ranking, start=1):
scores[passage_id] += 1 / (k + rank)
return sorted(scores, key=lambda pid: (-scores[pid], pid))Use exact phrase search when the reader explicitly requests a quote. Use the combined results for exploratory questions. Show the quote and its surrounding context so a reader can distinguish a relevant match from a plausible one.
Evaluate on real queries
The five-passage run illustrates the behavior of each method. To evaluate a larger index, collect queries that look like real editing work and label their expected timestamps before comparing methods.
- Exact quotes and names. Include uncommon spellings and transcription errors. Check that literal search behaves predictably.
- Paraphrases and follow-ups. Include answers given later in the recording, repeated phrases from different speakers, and questions with no answer.
- Cost and quality. Record whether the correct span appears in the top results, how far down it lands, and how long lookup takes. Keep test queries separate from tuning queries.
ClipMill exposes timestamped recording search through its CLI and MCP server. This worked example uses rank fusion to show how the approaches interact. The ClipMill recording search guide shows how to query recordings in the app.
References
- SQLite FTS5Phrase syntax, tokenizers, and BM25 ranking.
- Multilingual E5 smallModel inputs, pooling, and vector normalization.
- Reciprocal Rank FusionThe original rank-combination method, SIGIR 2009.