fork of https://github.com/sourcegraph/zoekt
1
2 "Zoekt, en gij zult spinazie eten" - Jan Eertink
3
4 ("seek, and ye shall eat spinach" - My primary school teacher)
5
6Zoekt is a text search engine intended for use with source
7code. (Pronunciation: roughly as you would pronounce "zooked" in English)
8
9**Note:** This has been the maintained source for Zoekt since 2017, when it was forked from the
10original repository [github.com/google/zoekt](https://github.com/google/zoekt).
11
12## Background
13
14Zoekt supports fast substring and regexp matching on source code, with a rich query language
15that includes boolean operators (and, or, not). It can search individual repositories, and search
16across many repositories in a large codebase. Zoekt ranks search results using a combination of code-related signals
17like whether the match is on a symbol. Because of its general design based on trigram indexing and syntactic
18parsing, it works well for a variety of programming languages.
19
20The two main ways to use the project are
21* Through individual commands, to index repositories and perform searches through Zoekt's [query language](doc/query_syntax.md)
22* Or, through the indexserver and webserver, which support syncing repositories from a code host and searching them through a web UI or API
23
24For more details on Zoekt's design, see the [docs directory](doc/).
25
26## Usage
27
28### Installation
29
30 go get github.com/sourcegraph/zoekt/
31
32**Note**: It is also recommended to install [Universal ctags](https://github.com/universal-ctags/ctags), as symbol
33information is a key signal in ranking search results. See [ctags.md](doc/ctags.md) for more information.
34
35### Command-based usage
36
37Zoekt supports indexing and searching repositories on the command line. This is most helpful
38for simple local usage, or for testing and development.
39
40#### Indexing a local git repo
41
42 go install github.com/sourcegraph/zoekt/cmd/zoekt-git-index
43 $GOPATH/bin/zoekt-git-index -index ~/.zoekt /path/to/repo
44
45#### Indexing a local directory (not git-specific)
46
47 go install github.com/sourcegraph/zoekt/cmd/zoekt-index
48 $GOPATH/bin/zoekt-index -index ~/.zoekt /path/to/repo
49
50#### Searching an index
51
52 go install github.com/sourcegraph/zoekt/cmd/zoekt
53 $GOPATH/bin/zoekt 'hello'
54 $GOPATH/bin/zoekt 'hello file:README'
55
56### Zoekt services
57
58Zoekt also contains an index server and web server to support larger-scale indexing and searching
59of remote repositories. The index server can be configured to periodically fetch and reindex repositories
60from a code host. The webserver can be configured to serve search results through a web UI or API.
61
62#### Indexing a GitHub organization
63
64 go install github.com/sourcegraph/zoekt/cmd/zoekt-indexserver
65
66 echo YOUR_GITHUB_TOKEN_HERE > token.txt
67 echo '[{"GitHubOrg": "apache", "CredentialPath": "token.txt"}]' > config.json
68
69 $GOPATH/bin/zoekt-indexserver -mirror_config config.json -data_dir ~/.zoekt/
70
71This will fetch all repos under 'github.com/apache', then index the repositories. The indexserver takes care of
72periodically fetching and indexing new data, and cleaning up logfiles. See [config.go](cmd/zoekt-indexserver/config.go)
73for more details on this configuration.
74
75#### Starting the web server
76
77 go install github.com/sourcegraph/zoekt/cmd/zoekt-webserver
78 $GOPATH/bin/zoekt-webserver -index ~/.zoekt/
79
80This will start a web server with a simple search UI at http://localhost:6070. See the [uuery syntax docs](doc/query_syntax.md)
81for more details on the query language.
82
83If you start the web server with `-rpc`, it exposes a [simple JSON search API](doc/json-api.md) at `http://localhost:6070/search/api/search.
84
85Finally, the web server exposes a gRPC API that supports [structured query objects](query/query.go) and advanced search options.
86
87## Acknowledgements
88
89Thanks to Han-Wen Nienhuys for creating Zoekt. Thanks to Alexander Neubeck for
90coming up with this idea, and helping Han-Wen Nienhuys flesh it out.