The technology behind GitHub’s new code search
GitHub 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.
Related posts
- A brief history of code search at GitHub
GitHub Engineering mediumAdeptGitHub'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.
- 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.
- Indexing code at scale with Glean
Meta Engineering mediumAdeptGlean is Meta's open-source code indexing system that stores arbitrary language-specific facts about source code in RocksDB and exposes them through Angle, a declarative logic-based query language that can derive language-neutral views, much like SQL views. Incremental indexing stacks immutable databases so each layer can add or hide facts, which brings indexing cost down to O(fanout) rather than O(repository) and lets the index serve multiple revisions without full copies. At Meta, Glean, together with the Glass symbol server, powers cross-language code navigation and C++ IDE acceleration alongside clangd. It also drives generated documentation, stable symbol IDs and diff sketches for code review, static analysis and commit search, with simple queries returning in about a millisecond.
- How Hugging Face Inference Endpoints, Jobs, and Buckets Power Search on Papers with Code
Hugging Face mediumAdeptPapers with Code search combines PostgreSQL full-text search with pgvector semantic search over Qwen3-Embedding-0.6B vectors, fused by weighted reciprocal rank fusion (k=60), with exact-title, arXiv-ID and navigational matches pinned on top. Hugging Face Jobs build the full corpus on an L4 GPU from checksummed snapshots stored in immutable run prefixes in Storage Buckets. A scale-to-zero TEI Inference Endpoint embeds live queries and hourly incremental updates. A strict versioned embedding contract (pinned revision, 256-dim Matryoshka vectors, query/document prompts, content hashes) keeps generations reproducible, and pilot tests showed 0.9955 Recall@20 at ~1.3 ms p50 with 27% of the 1024-dim storage. A one-second timeout and circuit breaker fall back to lexical search when the endpoint is cold or unhealthy.