Zvec Logo

Search Guide

Choose a retrieval route, narrow the workspace, and tune Zvec-Grep results.

Zvec-Grep offers complementary routes behind one zg query command. Start with the route that matches what you know, then narrow the search space before increasing the result count.

Choose a Route

Your intentCommandBehavior
Discover by meaning or combine meaning with keywordszg query "authentication flow"Hybrid ranked sample
Rank known terms by relevancezg query --fts "AuthService"BM25-ranked sample
Search only by conceptual similarityzg query --vector "where credentials are validated"Vector-ranked sample
Find every literal or regex occurrencezg query --rg -n -F "AuthService" srcExhaustive unless bounded

Use --rg for exact or exhaustive work. Use indexed retrieval when wording or location is unknown, or when the answer requires relationships across files.

The default positional query combines lexical and vector retrieval:

zg query --human "where are user preferences restored at startup" --limit 5

When a question also contains exact anchors, fuse them into one ranked plan:

zg query --hybrid "authentication flow" --fts "ForbiddenError" --fuse --limit 10

Narrow the Workspace

zg query "plugin lifecycle" -g "src/**" -g "!src/generated/**" -t ts
OptionUse it to
-g, --glob, --iglobInclude or exclude paths
-t, --type, -T, --type-notFilter file types
--modified-after / --modified-beforeFilter by modification time

Control Results and Freshness

OptionEffect
--limit <n>Maximum results per query group
--humanFuller terminal-oriented previews
--preview none|short|fullIndexed source preview size
--debug / --traceQuery and per-hit diagnostics
--refresh background|wait|offIndex freshness policy

Indexed results report fresh or possibly_stale. Use --refresh wait only when the latest file changes must be included.

Improve Weak Results

  1. Confirm the workspace root and index state with zg status.
  2. Restrict the query to relevant paths or file types.
  3. Add one or two concrete anchors with --fts.
  4. Switch to --rg when the target text is known.
  5. Review Supported Content and the selected Embedding Models.

Run zg help query for the installed version's complete flag reference. If results remain weak, follow Troubleshooting.

On this page