A brief history of code search at GitHub
GitHub's code search evolved from a public-only Solr index plus `git grep` for private repos, to a decade-long Elasticsearch deployment that grew to 162 nodes, 1.25PB of storage and over 53 billion indexed files. Natural-language text analysis fits source code poorly. GitHub's custom tokenizer dropped punctuation and could not do substring or regex matching. An experiment that indexed special characters made indexing 43-100% slower, grew the index 18-28% and slowed typical queries about 2.1x. A short-lived exact-match beta also failed to balance its resource cost against corpus growth. Existing trigram engines like Russ Cox's and Zoekt also fell short at GitHub's scale, so GitHub built Blackbird, a bespoke engine targeting sub-second p95 global exact-match and regex queries without using much more resources than the Elasticsearch cluster.
Related posts
- The technology behind GitHub’s new code search
GitHub Engineering mediumAdeptGitHub built Blackbird, a Rust code search engine, because general text search engines handled punctuation, regex, and GitHub's scale poorly, and brute-force grep would yield about 0.01 QPS. It uses ngram inverted indices with lazily intersected posting-list iterators, shards by Git blob ID to deduplicate content, and delta-encodes repositories ordered by a similarity-based minimum spanning tree. Kafka decouples crawling from indexing and provides commit-level query consistency. Shards serve queries at about 100 ms p99 (roughly 640 QPS per 64-core host), and 115 TB of code fits in a 25 TB index that can be fully rebuilt in about 18 hours.
- How GitHub Docs’ new search works
GitHub Engineering mediumAdeptGitHub Docs replaced its in-memory Node.js site search, which loaded serialized indexes from the Git repo for eight languages and five versions, with Elasticsearch. Each search is sent as one query built from a matrix of fields (title, headings, content), two analyzers (explicit with no stemming or synonyms, and Snowball-stemmed) and match types (phrase, AND, OR, fuzzy). Each combination gets a distinct multiplicative boost, so exact title phrase matches rank highest and terms like `working-directory` aren't swamped by stemmed matches. Final scores are multiplied by (1 + normalized pageview popularity), and query execution stays around 20 ms server-side.
- Fast regex search: indexing text for agent tools · Cursor
Cursor mediumAdept
Agents lean heavily on regex search, and ripgrep's full scan can take over 15 seconds in large monorepos, so Cursor builds local indexes specifically to accelerate regex queries. The post traces the lineage of regex indexing: n-gram inverted indexes from Zobel et al. (1993) and Russ Cox's Google Code Search trigram approach, including how regexes are decomposed into trigram AND/OR queries, then livegrep's suffix arrays and GitHub Project Blackbird's trigram posting lists augmented with probabilistic masks (position and next-character bloom filters) to approximate '3.5-grams'. It weighs the tradeoffs of each: index size, query decomposition cost, and difficulty of dynamic updates.
- GitHub Issues search now supports nested queries and boolean operators: Here’s how we (re)built it
GitHub Engineering mediumAdeptGitHub rebuilt Issues search to support AND/OR operators and nested parentheses by replacing the flat-list parser with a PEG grammar (via the Ruby parslet library) that produces an abstract syntax tree. That tree is recursively traversed into nested Elasticsearch bool queries, with AND and OR mapped to must and should clauses. To protect backward compatibility at roughly 2,000 QPS, the team reran the existing test suites with the feature flag on and off and dark-shipped 1% of searches through both systems using the scientist library, comparing result counts and performance. The rollout capped nesting at five levels and started with the GraphQL API and the repository Issues tab before expanding to the dashboard and REST API.
- Building a code search engine with Turso
Turso mediumAdeptCodemogger is an open-source code indexer and search engine for AI agents, built on a single local Turso (SQLite-compatible) file using native vector columns and full-text search. Tree-sitter splits code into function and struct chunks, which are embedded locally with all-MiniLM-L6-v2 and stored as int8-quantized vector8(384) columns (395 vs 1,536 bytes per vector). Brute-force cosine search over 40,000 TypeScript compiler chunks takes about 240ms on an M2, and BM25 keyword search with name/signature weights takes 1-4ms. Results are merged with Reciprocal Rank Fusion (0.6 vector, 0.4 FTS), and a TypeScript SDK accepts any embedding function and indexes incrementally by file hash.