toc: modify disk format to include names for backwards/forwards compatiblity.

Including section names in the table of contents permits simpler
forwards and backwards compatibility. Instead of having to bump
the entire IndexFormatVersion when a new section is added, there is
simply a new section present in the table of contents.

Older versions can read TOCs with unknown sections and skip over them
with a warning. This is useful to permit downgrades without always
requiring a reindex.

Newer versions can read TOCs from older version with missing sections
and handle them gracefully, by checking for empty sections when loading
an index file and implementing whatever fallback code is necessary.

Section evolution is possible by having a new name for a tagged section,
adding the old section to the CompatibilityList, and writing the
conversion code when loading the file, or modifying the users of the
section to use whichever one is loaded.

Change-Id: I9aa05f29eb9d64fd0fff218f008d2031f1a15c8c
7 files changed
tree: 4e8e8bd242c88d4fddc3a6f2521789314b0ce239
  1. .gitignore
  2. CONTRIBUTING
  3. LICENSE
  4. README.md
  5. all.bash
  6. api.go
  7. bits.go
  8. bits_test.go
  9. build-deploy.sh
  10. build/
  11. cmd/
  12. contentprovider.go
  13. ctags/
  14. doc/
  15. eval.go
  16. eval_test.go
  17. gitindex/
  18. go.mod
  19. go.sum
  20. hititer.go
  21. hititer_test.go
  22. index_test.go
  23. indexbuilder.go
  24. indexdata.go
  25. indexfile_other.go
  26. indexfile_unix.go
  27. matchiter.go
  28. matchtree.go
  29. matchtree_test.go
  30. query/
  31. read.go
  32. read_test.go
  33. section.go
  34. section_test.go
  35. shards/
  36. testdata/
  37. toc.go
  38. web/
  39. write.go
README.md
"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)

INSTRUCTIONS

Downloading:

go get github.com/google/zoekt/

Indexing:

go install github.com/google/zoekt/cmd/zoekt-index
$GOPATH/bin/zoekt-index .

Searching

go install github.com/google/zoekt/cmd/zoekt
$GOPATH/bin/zoekt 'ngram f:READ'

Indexing git repositories:

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

Indexing repo repositories:

go install github.com/google/zoekt/cmd/zoekt-{repo-index,mirror-gitiles}
zoekt-mirror-gitiles -dest ~/repos/ https://gfiber.googlesource.com
zoekt-repo-index \
   -name gfiber \
   -base_url https://gfiber.googlesource.com/ \
   -manifest_repo ~/repos/gfiber.googlesource.com/manifests.git \
   -repo_cache ~/repos \
   -manifest_rev_prefix=refs/heads/ --rev_prefix= \
   master:default_unrestricted.xml

Starting the web interface

go install github.com/google/zoekt/cmd/zoekt-webserver
$GOPATH/bin/zoekt-webserver -listen :6070

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

[Unit]
Description=zoekt webserver

[Service]
ExecStart=/zoekt/bin/zoekt-webserver -index /zoekt/index -listen :443  --ssl_cert /zoekt/etc/cert.pem   --ssl_key /zoekt/etc/key.pem
Restart=always

[Install]
WantedBy=default.target

SEARCH SERVICE

Zoekt comes with a small service management program:

go install github.com/google/zoekt/cmd/zoekt-indexserver

cat << EOF > config.json
[{"GithubUser": "username"},
 {"GithubOrg": "org"},
 {"GitilesURL": "https://gerrit.googlesource.com", "Name": "zoekt" }
]
EOF

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

This will mirror all repos under ‘github.com/username’, ‘github.com/org’, 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.

SYMBOL SEARCH

It is recommended to install Universal ctags to improve ranking. See here for more information.

ACKNOWLEDGEMENTS

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

DISCLAIMER

This is not an official Google product