Fast trigram based code search

Clone this repo:


  1. 19f5cbf build: Fix racy write to finishedShards map by Han-Wen Nienhuys · 9 days ago master
  2. 82cc198 Dismantle the docIterator type by Han-Wen Nienhuys · 11 days ago
  3. 35c76e3 Introduce bruteForceMatchTree by Han-Wen Nienhuys · 11 days ago
  4. 904e38b Add nextDoc to the matchTree interface by Han-Wen Nienhuys · 11 days ago
  5. 3b43670 Drop unused member in regexpMatchTree by Han-Wen Nienhuys · 12 days ago
"Zoekt, en gij zult spinazie eten" - Jan Eertink

("seek, and ye shall eat spinach" - My primary school teacher)

This is a fast text search engine, intended for use with source code. (Pronunciation: roughly as you would pronounce “zooked” in English)



go get


go install
$GOPATH/bin/zoekt-index .


go install
$GOPATH/bin/zoekt 'ngram f:READ'

Indexing git repositories (requires libgit2 + git2go):

go install
$GOPATH/bin/zoekt-git-index -branches master,stable-1.4 -prefix origin/ .

Indexing repo repositories (requires libgit2 + git2go):

go install{repo-index,mirror-gitiles}
zoekt-mirror-gitiles -dest ~/repos/
zoekt-repo-index \
   -name gfiber \
   -base_url \
   -manifest_repo ~/repos/ \
   -repo_cache ~/repos \
   -manifest_rev_prefix=refs/heads/ --rev_prefix= \

Starting the web interface

go install
$GOPATH/bin/zoekt-webserver -listen :6070

A more organized installation on a Linux server should use a systemd unit file, eg.

Description=zoekt webserver

ExecStart=/zoekt/bin/zoekt-webserver -index /zoekt/index -listen :443  --ssl_cert /zoekt/etc/cert.pem   --ssl_key /zoekt/etc/key.pem



Zoekt comes with a small service management program:

go install

cat << EOF > config.json
[{"GithubUser": "username"},
 {"GitilesURL": "", Name: "zoekt" }

$GOPATH/bin/zoekt-server -mirror_config config.json

This will mirror all repos under ‘’ as well as the ‘zoekt’ repository. It will index the repositories.

It takes care of fetching and indexing new data and cleaning up logfiles.

The webserver can be started from a standard service management framework, such as systemd.


It is recommended to install CTags to improve ranking:

  • Universal ctags is more up to date, but not commonly packaged for distributions. It must be compiled from source.
  • Exuberant ctags is a languishing, but commonly available through Linux distributions. It has several known vulnerabilities.

If you index untrusted code, it is strongly recommended to also install Bazel's sandbox, to avoid vulnerabilities of ctags opening up access to the indexing machine. A blessed version of the sandbox is under cmd/zoek-sandbox. It can be compiled with a simple make call.


Thanks to Alexander Neubeck for coming up with this idea, and helping me flesh it out.


This is not an official Google product