Search
Full-text search over every item a user has: read or unread, from sources they follow, paused or have unfollowed (starred items stay) (SI-530). In the app: Search (/search), or press / anywhere. Code: packages/core/src/services/search.ts, the page in apps/web/src/routes/(app)/search/.
Searching
Results come as you type. Each shows the source, the date, the title with the hits marked, and a snippet of the text around the hits. Items a filter rule mutes are found too, marked “Muted by” and the rule (filters.md). A result opens the item; Escape returns to the search. The URL holds the search and its filters, so it can be bookmarked or shared.
| Type | Finds |
|---|---|
svelte runes |
Items with both words |
"server side" |
The exact phrase |
rust -game |
Items with rust but without game |
type* |
Words that start with type |
title:svelte |
svelte in the title only. Also author:, source:, body: |
The last word matches as a prefix while it is typed (firefl finds fireflies); a space after it ends that. Case and accents don’t matter: cafe finds Café. Anything else in the input is taken as text, never as FTS5 syntax, so no input can break the query.
Filters: source, kind (articles, or videos: YouTube), state (unread, read, starred), a date range (the To day counts in full, in the browser’s time zone), and the order: best match (default) or newest first.
What is indexed
The index is an SQLite FTS5 table, items_fts, with four columns, weighted for ranking (bm25):
| Column | From | Weight |
|---|---|---|
title |
items.title |
10 |
author |
items.author |
3 |
source |
the source’s own title (sources.title) |
2 |
body |
the text of items.content, or items.excerpt when there is no content |
1 |
body is text, not HTML: the triggers pass the content through html_text(), a function openDatabase() registers on every connection (it uses htmlToText() from feeds/normalize.ts). A connection opened without it, such as the sqlite3 shell, can read but not write items.
A user’s own name for a subscription is not indexed: the index is shared by all users. The source filter covers that case.
After 90 days the retention clears an item’s content (data-model.md); its index row then holds the excerpt, so old items are still found by title, author, source and excerpt. Starred items keep their content, and so their full text.
Staying in sync
Triggers keep the index in step with the tables, whatever writes them (migration 0007_full_text_search):
- insert on
items: gives the item itssearch_rowidand indexes it - update of title, author, excerpt or content: reindexes the item (full article loaded, content pruned)
- delete on
items, also through a deleted source’s cascade: removes its row - update of
sources.title: updates thesourcecolumn of its items
The index row is linked by items.search_rowid, not by the implicit rowid: items has a text primary key, so VACUUM may renumber its rowids.
Speed
The goal is under 200 ms per page on a year of items, about 180,000. Each plan hands its order to an index, so a page costs about the same whether a query matches ten items or all of them:
- Best match: FTS5 yields matches best first (
order by rank, with the weights set byrank match), and the joins check them only until the page is full. With filters that leave few items (a source, starred only, or read state and dates that count at most 20,000 items), the filtered items are collected first and the matches ranked among them; otherwise the filters would check nearly every match. - Newest first: walk the user’s stream index (
user_items (user_id, published_at)) newest first, keeping the items in the set of matches. - Highlights and snippets are built in a second query, for the page only.
Measured on 180,000 generated items (the last 90 days with full content), on an Apple M5 Pro:
| Search | Time |
|---|---|
| A rare word | 1–6 ms; with filters up to 35 ms |
| A phrase | 8 ms |
| A word in 55% of items, best match | 35 ms |
| A word in 98% of items, best match | 80 ms |
| The same, newest first | 12 ms |
| The same, unread videos of the last 30 days | 120 ms |
Prefix d* |
65 ms |
Tests check the query plans: no plan sorts all matches in a temporary table.
API
GET /api/v1/search?q=… with a read token; the SDK’s client.search().
| Parameter | |
|---|---|
q |
What to search for, as above. Required |
source |
A source ID |
type |
article or video |
from, to |
ISO 8601 date-times: published at or after from, before to |
starred, read |
true or false |
sort |
relevance (default) or newest |
limit, offset |
1–100 (default 30); offset from the previous page’s nextOffset |
Each result is a stream item plus titleParts and snippet: lists of { text, match } pieces, so clients mark the hits without parsing HTML.