chloedb-hn: Hacker News on ChloeDB
Reference, rendered from docs/chloedb/hn.md.
These docs describe release 0.3.11. The docs of main describe the code as it is now.
On this page
A demo. chloedb-hn shows what ChloeDB can do; it is not part of ChloeDB's releases or their promises. It is tested on a train of its own (the
Demosworkflow,.github/workflows/demos.yml), outside CI's required check, and the command center marks it as a demo (compatibility).
chloedb-hn keeps every public Hacker News item in ChloeDB, about 49 million stories, comments, jobs and polls from October 2006 on, and searches them the way people look for things on HN: a story they half remember, what HN said about a tool, who knows a subject, when something was talked about, or a question asked in a sentence.
- Questions in a sentence, answered by SQL, no model. "which post has received the most comments", "who posted the most stories about rust", "how many Show HN posts about postgres in 2023", "when was HN most into bitcoin", "what was the first story about docker". A small grammar (
src/nl.rs) reads the question into what it asks (the top item by a measure, a count, people, sites or years), the topic and the filters, and the answer above the results is one query, shown with it. Anything the grammar does not read is searched as words. - Autocomplete of questions, phrases and people. As a search is typed the box offers whole questions the grammar reads (
which post→ "which post has received the most comments"), the phrases HN's titles use most (kubernetes o→ "kubernetes operator"), people and sites. The phrases are a table,hn_complete, keyed by kind and text, so completing is a prefix of its sorted key: one run of the dictionary, read from a few blocks (PREFIX(id, 'p:kubernetes o')). - Instant, a keystroke at a time. Each keystroke shows the stories whose titles hold the words typed so far, the last one as a word or the start of one (
rust asyisMATCH(title, 'rust (asy OR asy*)')), by points while that word is being typed and by BM25 times the votes once a space follows it: one statement, no count, no meaning. Enter runs the full search, which reads the last word whole. It is off until the Instant switch beside the box turns it on, and it and Fast are one at a time: switching one on switches the other off. A question being typed still gets its completions. - Words and meaning together. Titles, texts and the words of each link are ranked by BM25 with typos, stems and synonyms, fused with a static embedding model's similarity on the server, and weighed by points (
pow(points + 1, 0.35)) and a gentle decay for age. Every word must be there for searches of up to three words, and most of them for longer ones, so the counts and facets match the results. - Exact text, punctuation and all.
`C++`,`std::move`,`k8s.io/api`in backticks, or Match by → exact text, are matched where their characters are, byILIKEanswered from each segment's FM-index (OPTIONS(substring = true)), which tokenized search cannot do. - Highlights the way the index reads. A server of 0.3.7 or later marks each result with
POST /v1/highlight: stems, synonyms, typos and code as the field's analyzer reads them, cut to the stretch with the most matches. - Filters in the words.
by:pg,site:github.com,points>500,comments>100,2019..2021,before 2015,-crypto,show hn,ask hn,"exact phrase"; each is shown as a removable chip of what was understood. - Threads, people and the graph. A story opens as its whole thread; a comment opens in place with the path to it. People pages show what someone writes about, when, and who they talk to (the reply graph,
hn_replies). Who knows ranks the people who comment most on a subject, weighed by the discussion they start. Similar stories by meaning, and the same link discussed again. - What HN thinks. A question about opinions gathers the comments that speak to it, packed into a model's budget by the database (
PACK n TOKENS ... DEDUPE ... WITH RECEIPT), and a model behind the server'sllm()sums them up with every claim cited to a numbered comment. Answers are kept, so a question asked again costs nothing. It, Weekly and Changed minds are the parts that call a model. - A link across HN. Links takes a page or a site and shows everywhere HN met it: each time it was submitted, the comments that cite it in other threads, the people who submitted, discussed or cited it, and the links discussed beside it, drawn as one graph (
GET /v1/link?u=). A site alone (sqlite.org) lists its most discussed pages, the pages submitted again and again, and who posts it most. - The week on HN. Weekly is a digest of a week's ten most voted stories (one per link, jobs left out): what each is, why it mattered, what the thread said, with the top comments quoted, and an opening over the whole week. The app reads each story's linked page once (public
httpandhttpspages only, with a timeout) andllm()writes an entry from the page, the post and its most replied comments; entries are kept inhn_answers, so each story is written once (--digest-model, at most--digest-per-daynew entries a day). - The canon. Canon ranks the books and papers HN recommends, by the people who linked or named each, one person once: for all years, for a span of them (
2010..2014) or by a word of the title. A work's page shows the people who named it a year, its best received comments with the name marked, and how it was counted.canon/build.pybuildshn_canonfrom the cluster: the comments that link Amazon, Goodreads or arXiv, the works' titles from Open Library and the arXiv API, books merged across editions by title and first author, then every work counted. A comment counts when it links the work, uses its short name (SICP), writes the title as a title (each word capitalised: "Getting Things Done", not "getting things done") beside a word about books or papers, or writes it beside one of its authors' names, which is the only way to name a title of one or two words ("Steve Jobs", "Deep Learning"); a paper counts only from the year of its arXiv id. So a title that is also a common phrase, a person or a subject ("World Models", "On Writing") is not counted every time it is written. - Changed minds. For a topic (
rust,bitcoin,remote work), the people who wrote about it in four years or more, and for one of them an arc: their comments that BM25 finds most about it, three a year at most, read by a model throughllm()for where each stands (from -2, against, to 2, for, or no view when a comment only explains a detail) with a quote, and what they thought first and last; a year's stance is the mean of its comments that take a side, so neutral and technical comments are shown but do not move it. A quote the comment does not hold word for word is dropped, and every point links to its comment. Arcs are kept inhn_answers; a new one counts against--ask-per-day. - Fast mode. The switch beside the search box ranks by words alone (BM25, no meaning and no reranking) for every search until it is switched off.
- Live. With
--feedthe app follows the HN API: new items as they are posted, and the points and comments of the stories that change.
Like the crawler and network operations, it is a program of its own, in Rust, that talks to chloedb-server over HTTP only, and the command center shows it as an app (Apps → Hacker News).
Run it#
Build both programs, then prepare the archive and start the app with a server of its own:
(cd chloedb-server && cargo build --release --bin chloedb-server) cd chloedb-hn && cargo build --release target/release/chloedb-hn prepare --parquet ./hn-parquet --out ./hn-rows --download target/release/chloedb-hn complete --rows ./hn-rows target/release/chloedb-hn serve --local ./hn-data --rows ./hn-rows --server-bin ../chloedb-server/target/release/chloedb-server
prepare --download fetches the archive's monthly Parquet files (about 12 GB, from open-index/hacker-news) and writes the app's rows: stories, comments (each with its story's title, depth, place among its siblings and the discussion under it), people, the reply graph and the links between stories. --from 2024-01 and --to take part of it; --comments-since keeps every story and only the newer comments. complete writes autocomplete's rows from them. serve --local DIR starts a chloedb-server with its database in DIR, makes the tables, loads the rows when they are empty, and lists the app as hn; open http://127.0.0.1:7700 and go to Apps → Hacker News.
Against a server or a cluster that runs elsewhere, load into it and give the server the app:
chloedb-hn load --rows ./hn-rows --strata http://coordinator:7700 --key "$CHLOEDB_KEY" --comment-model none chloedb-hn serve --strata http://coordinator:7700 --key "$CHLOEDB_KEY" --token "$HN_TOKEN" --listen 0.0.0.0:7850 --feed --comment-model none chloedb-server ... --app hn=http://hn-host:7850 # with CHLOEDB_APP_TOKEN=$HN_TOKEN
--comment-model none keeps the comments without vectors: they take a third of the bytes, and are found by their words and their story's title. The people and sites questions group by author or site; a server whose --max-groups (65,536 by default) is below HN's 1.1 million authors answers them for a topic but not over the whole archive, so give it --max-groups 2000000.
The questions it reads#
| asked | answered by |
|---|---|
| which post has received the most comments / the most upvoted story about X / the top 5 Show HN posts in 2023 | the top stories by comments, points or date, with the question's filters (ORDER BY comments DESC) |
| the first / oldest / newest story about X | ORDER BY created |
| how many stories mention X / number of comments about X in 2020 | COUNT(*) with the same match as the results, and its years |
| who posted the most about X / who commented the most / who has the most karma | GROUP BY author; HN's archive carries no karma, so karma is the points a person's stories earned, and the answer says so |
| who knows the most about X | the people who comment most on it, weighed by the discussion they start |
| which sites are posted the most about X | GROUP BY site |
| when was HN most into X / which year did X peak | the years' counts, each as a share of that year's stories (HN grew; raw counts favour late years) |
| what does HN think about X | the cited summary above, the one answer a model writes |
Each answer shows its SQL (see the SQL). The grammar's templates are also autocomplete's questions, so what the box offers it can answer.
Read the linked pages#
chloedb-hn crawl --strata http://coordinator:7700 --key "$CHLOEDB_KEY" --min-points 3 --contact https://your.site
crawl reads each page the stories link to, once, into hn_pages, with the crawler's fetcher and frontier: robots.txt read before a site's first page and obeyed, one request at a time to a site and a second between two (longer when its robots.txt or its answers ask), redirects checked hop by hop, public addresses only, HTML only, at most 5 MB a page. The links are the stories' canonical links (curl) of at least --min-points points, most voted first. Every link asked becomes a row saying what came of it (ok, noindex, robots, http_4xx with its code, network, timeout, not_html, ...), so the table also says which of HN's links still answer, by the year HN first linked them. A page whose <meta name="robots"> says noindex keeps no text. A run skips the links already in the table, so a crawl that stops goes on where it was; --again network,timeout asks those that failed that way again. --contact goes in the user agent, for a site's owner to reach whoever runs it.
Tables#
| table | what |
|---|---|
hn_stories |
stories, Ask and Show HN, jobs and polls: title, text, link (its site and words), author, time, points, comments, kind, topics, a vector of the title and text |
hn_comments |
comments: text, author, time, parent and its author, story and its title, depth, place among siblings, replies, the discussion under it (and a vector, unless --comment-model none) |
hn_users |
people: stories, comments, points earned, first and last item, replies received, people talked to |
hn_replies |
the reply graph: who replied to whom, how often |
hn_links |
which discussion links to which: a story or one of its comments naming another's item?id= |
hn_pages |
the linked pages as crawl read them, keyed by canonical link: what came of asking, the HTTP code, the year HN first linked it, the most voted story and how many link it, the page's title, description, text (at most --max-text characters), words, language, date, author and image, and a vector of its title, description and text |
hn_canon |
the canon: a row a book or paper, with its title, authors, cover, link, the people who named it in all and a year, its best received comments, the statement that found its candidates, the rule that kept them and how many each part kept |
hn_complete |
autocomplete: phrases of titles (p:), sites (s:), topics (t:) and people (u:), each with how many stories hold it and their points |
hn_answers, hn_searches, hn_state |
kept answers, the searches people ran (their words and counts only) and the feed's place |
The API#
| route | what |
|---|---|
GET /v1/search?q=&only=all\|story\|comment&sort=best\|date\|points\|comments&mode=hybrid\|words\|meaning\|exact\|fast\|instant&page= |
results, what was understood, the answer when it is a question, facets, "did you mean", and every query run with its time |
GET /v1/suggest?q= |
completions: questions, phrases, people, sites, stories |
GET /v1/item/:id, /v1/item/:id/around |
a thread; similar stories and the same link again |
GET /v1/user/:id, /v1/experts?q= |
a person; who knows a subject, with the replies among them and the community around them (brief=1: the people only) |
GET /v1/trends?q=a,b&by=year\|month |
how often each was talked about |
GET /v1/ask?q= |
what HN thinks, cited |
GET /v1/front |
the front page as SQL: points over age, as HN ranks it |
GET /v1/facets?q= |
a search's facets on their own (the page asks for them once the results are shown) |
GET /v1/ask/comments?q= |
the comments an answer is made from, before the model is asked |
GET /v1/trending, /v1/spikes?year= |
what titles are suddenly about (the last hours against the year before); the months' strongest spikes |
GET /v1/link?u= |
a page or a site across HN: its submissions, citing comments, people, related links and the graph of them; with no u, the most discussed stories |
GET /v1/digest?week=YYYY-MM-DD |
a week's digest: the stories picked, the entries and opening already written, the week's totals; the last full week by default |
GET /v1/canon?kind=book\|paper&from=&to=&q=, /v1/canon/work?id= |
the canon, ranked by everyone or by the people of the years asked; one work with its comments and how it was counted |
GET /v1/minds?topic=, /v1/minds/arc?topic=&who= |
the people who wrote about a topic for years, with the arcs already read; one person's arc (read and kept when it is new) |
GET /v1/digest/write?week=&id= |
writes one entry (id a story of the week's picks, or intro) and keeps it |
Experiments#
The Experiments app (its README) can study this site's real search. It puts AI agents, playing people written from the stories, on the search with some of it changed. The app takes experiments only when it is started with a token for them:
chloedb-hn serve ... --experiments-token "$HN_EXPERIMENTS_TOKEN" --experiment-index v2=hn_stories_v2 chloedb-experiments serve ... --source hn=app:http://hn-host:7850 # with CHLOEDB_SOURCE_HN_TOKEN=$HN_EXPERIMENTS_TOKEN
The token (--experiments-token, or CHLOEDB_HN_EXPERIMENTS_TOKEN) opens only /v1/experiment. These routes read: they write nothing, and hold no key of the cluster. They answer in --public mode too. Without the token they answer 404, and with a wrong one 401.
| route | what |
|---|---|
GET /v1/experiment |
the site, its knobs, presets and indexes |
POST /v1/experiment/search |
{q, knobs, per}: the site's own search of stories, with the knobs, and what it understood |
GET /v1/experiment/item/:id |
a story's title, link and text |
GET /v1/experiment/sample?n=&seed= |
stories to write people from: well voted and ordinary, across the years |
GET /v1/experiment/log?since=&limit= |
with --explore-share: the page's logged searches since since (seconds), each with the stories as ranked, as shown and opened, and the policy |
GET /v1/experiment/interleave, POST /v1/experiment/interleave, POST /v1/experiment/interleave/stop, GET /v1/experiment/interleave/log |
the test interleaving two arms on the page's searches: what runs, start one, stop it, read its searches (below) |
The knobs, by group (an arm names the ones it changes; the rest stay as the site is):
| group | knobs |
|---|---|
| Query understanding | understand: "by pg", "in 2015", "ask hn", "points>100" and questions in a sentence become filters and sorts; off, every word is searched as typed |
| Retrieval | typos (fuzzy title words), synonyms, meaning (stories near the words in meaning are candidates and meaning counts in the ranking), exact (code such as std::move found as written by the substring index) |
| Ranking | votes (the exponent of points + 1), recency (the share of the score a five-year decay of age decides), meaning_weight, phrase (the words as a phrase in the title), body, link; rank, a whole ORDER BY expression of ChloeDB's SQL over hn_stories (:q, :phrase, :v) in place of them; tiers (every word in the title first) |
| Blending | max_per_site (a site's stories past this many in the page move below the others), fresh (places of the page for the best stories of the last year) |
| Index | index: main, or an index named by --experiment-index NAME=TABLE, the stories indexed another way (other analyzers, fields or embeddings) beside the main one |
A knob it does not have, a number out of its range, an index it was not given, or an expression with more than an expression in it (a ;, a comment, a statement's words) is refused with 400.
Exploring: the page's searches, logged#
With --explore-share ε (or CHLOEDB_HN_EXPLORE_SHARE; it needs --experiments-token), the page's searches are logged so that the Experiments app can value a ranking on what real people opened, off-policy, without serving it. A logged search is the page's own (log=1): the first page of stories by the best match, with words. The log holds the stories in the order the site ranked them, the order shown and the stories opened from it (GET /v1/click?r=&id=, which the page calls, kept only for a recent request that showed the story). With chance ε the top --explore-top (10) stories are shown in a uniform random order instead (the rank log's epsilon policy), so every story of the top has a known chance at every place. The draw is seeded by the request's id. A search through the API, the Experiments app's agents' included, is not logged. The tables are hn_explore_log and hn_explore_clicks, and a tune (Experiments) values the site as it is and its proposal on them.
Interleaving: two arms on real visitors' searches#
The Experiments app's last step before a decision. When it starts a test (POST /v1/experiment/interleave with {id, name, a, b, share}, a and b each a set of the knobs above), a share of the page's logged searches (log=1) runs both arms' searches and shows one list drafted from the two by team draft: a coin seeded by the request picks which arm chooses first in each round, and each round both place their best story not yet shown. Each search is kept in hn_interleave_log with its query, both arms' stories and times, the order shown, the arm that placed each story and the device (phone or not, from the page's width), and the clicks are the ones the page already logs. Only one test runs at a time; it keeps running across a restart until POST /v1/experiment/interleave/stop. GET /v1/experiment/interleave says what runs, and GET /v1/experiment/interleave/log?test=&since=&limit= reads its searches with their clicks.
Each logged row has a kind. drafted is an interleaved search. It also keeps meta, which gives each story's age in days and its site, and click_ts, the time each story was first opened. error is a search where an arm failed (err is a, b or ab): the page was served the usual way, and the row only counts the failure. While a test runs, the page's other logged searches by the same browser are kept as well. page is a next page of results (page holds its number). other is any other search. Those two rows let the app tell whether a drafted search was followed by a next page, or by a search in other words. The page links them with vid, an anonymous id of 16 random hex characters that the browser keeps in its local storage. The id is sent only with logged searches, and it names no account or address. Two arms that search alike are refused. No test runs until one is started.
Measured against hn.algolia.com#
eval/compare.py asks both the same queries, made from stories both hold: a story found again from three words of its title, the same with a typo, the story described in other words, and topics whose top ten a model grades blind to which engine found what. The results are in chloedb-hn/eval/results, with the machine and the date they were measured on.
eval/instant.py types six searches a character at a time and asks both at each keystroke, as their pages do. On 2026-11-16, while crawl was writing pages into the same cluster, the app's instant search took 10 ms at the median on the server (22 ms at the 90th percentile) against Algolia's 13.5 ms (34 ms), and its round trip from the same cloud machine 48 ms against Algolia's 199 ms (the numbers).
eval/latency.py times the same searches on both, each asked twice, as the server reports it and from end to end. On 2026-11-16 (a cloud machine against the deployment on DigitalOcean, four shards of 16 GB machines with the data on their own disks), the app's whole search took 100 ms at the median the first time a query was asked and 67 ms the second; hn.algolia.com's engine reported 17 ms, and its full round trip from the same machine was 243 ms against the app's 140 ms. eval/plain.py times the simplest statements on the same queries: BM25 of the titles alone took 15 ms at the median, as Algolia's 16.5, and the substring index with no ranking took 8 ms (the numbers).