Exograph includes Mix tasks for indexing and searching from the command line.

Indexing

Index the current project:

mix exograph.index --repo MyApp.Repo --migrate lib test

Useful options:

mix exograph.index --repo MyApp.Repo --migrate lib test --stats
mix exograph.index --repo MyApp.Repo --migrate --no-bm25 lib
mix exograph.index --repo MyApp.Repo --migrate --json lib

Searching

Structural search:

mix exograph.search 'Repo.get!(_, _)' --repo MyApp.Repo --migrate lib

Structural search with relationship filters:

mix exograph.search 'def _ do ... end' \
  --repo MyApp.Repo \
  --migrate lib \
  --contains 'Repo.transaction(_)'

mix exograph.search 'def _ do ... end' \
  --repo MyApp.Repo \
  --migrate lib \
  --contains 'Repo.transaction(_)' \
  --not-contains 'IO.inspect(_)'

Explain a query:

mix exograph.search 'Repo.get!(_, _)' --repo MyApp.Repo --migrate lib --explain

Text and regex search:

mix exograph.search '/users/:id' --repo MyApp.Repo --migrate lib --text
mix exograph.search 'Repo\.get!\(' --repo MyApp.Repo --migrate lib --regex

Backend flags

Postgres is the only built-in backend, but --backend postgres is accepted:

mix exograph.index --backend postgres --repo MyApp.Repo --migrate lib test
mix exograph.search 'Repo.get!(_, _)' --backend postgres --repo MyApp.Repo --migrate lib