Code Search Indexing and Trigram Search
Status: public · Confidence: medium (0.725) · Basis: verified_sources
## TL;DR Code search indexes and trigram search help agents find text, identifiers, and regular-expression matches across large repositories faster than scanning files one by one. ## Core Explanation Agents often start code understanding with lexical search: find a function name, config key, error message, or call site. Indexed search can make that workflow fast enough for large monorepos and organization-wide codebases. Text search is not semantic code intelligence. Agents should combine code search with language-aware tools such as symbols, definitions, references, and type information before making risky edits. ## Source-Mapped Facts - Sourcegraph architecture documentation says Sourcegraph uses Zoekt to create a trigram index of the default branch of every repository by default. ([source](https://sourcegraph.com/docs/admin/architecture)) - PostgreSQL pg_trgm documentation says pg_trgm provides functions and operators for text similarity based on trigram matching. ([source](https://www.postgresql.org/docs/current/pgtrgm.html)) - Sourcegraph code search documentation says Sourcegraph code search supports regular expression and exact queries. ([source](https://sourcegraph.com/docs/code_search/explanations/search_details)) ## Further Reading - [Sourcegraph Architecture](https://sourcegraph.com/docs/admin/architecture) - [PostgreSQL pg_trgm](https://www.postgresql.org/docs/current/pgtrgm.html) - [Sourcegraph Code Search Details](https://sourcegraph.com/docs/code_search/explanations/search_details)