FounderNest · Senior Product Engineer · 2022 to 2025
Company search fast enough to autocomplete
- MongoDB
- Atlas Search
- PostgreSQL
- RabbitMQ
- Node.js
- TypeScript
The problem
Users needed to find one company among 50M+ while typing. Results had to arrive on every keystroke, and the right company had to come first, even when dozens share a name.
My part
I was the link between the data and the product. The data team built the Atlas Search index and its ranking score; I built the experience that turned 50M+ records into something people loved using: the autocomplete on top of the index, the company logos, and the queues that kept the index in sync, including the RabbitMQ client every service ended up using.
Architecture
App data lived in PostgreSQL. Full company records lived in MongoDB. Atlas Search indexes sat on top and served the autocomplete straight from the index, so a keystroke never had to touch the full records. That is where the speed came from.
One company, many records
Typos and partial names were the easy part. The index handled them.
Duplicates were not. Company data came from several sources, and each described the same company its own way. Fuzzy matching made it worse: the better the search got at finding near matches, the more copies of the same company it showed.
So records had to be merged into one company before they were indexed, and that needed an identity. Names vary, legal names vary, descriptions vary. The website URL turned out to be the most useful property of all: the same everywhere, almost. It became the unique key.
Ranking by how much we knew
Type “Atlas” and hundreds of companies match. Text relevance alone can’t pick between them, and the one a user means is almost never an empty shell with a name and nothing else.
The data team built a score for that. Each company was weighted by the quantity and the quality of the data we had on it, so a well-documented company outranked a bare record with the same name.
The score lived in the index and put the whole collection in order ahead of time. A keystroke didn’t rank anything: it only filtered, and the matches were already sorted. Merging duplicates helped here too: one company with all its data scored higher than five fragments of it.
Logos
A row in an autocomplete is recognised by its logo before its name is read, so every result needed one. We first took them from each company’s own site: the favicon, the Open Graph image, the social profiles. It was the duplicates problem again. Every site did it differently, many images were missing, tiny or not a logo at all, and the results were inconsistent.
We settled on the Clearbit Logo API: send a domain, get a logo back. It fit because the URL was already each company’s identity. When Clearbit shut the API down we moved to Logokit. Either way we cached logos as hard as we could, because a logo almost never changes and every result row needs one.
Keeping the index in sync
Company records changed all the time. A cron job picked up changes and pushed them through RabbitMQ queues to be reindexed. Simple on paper. The queues were the hardest part of the whole system to get right.
What came out of it was a RabbitMQ client I wrote for all our services to share, published as foundernest-amqp-client (about 17,000 npm downloads in the past year). Its rules are fixed in the client so every service agrees on them: messages are persistent, each one gets three delivery attempts within 24 hours, and failures go to a dead-letter queue kept for 30 days so someone can see why. A dropped connection reconnects with exponential backoff and jitter, and listeners subscribe again on their own.
What I learned
Search quality was a data problem before it was a search problem. Once each company had one identity and a score for how much we knew about it, autocomplete got easy.