# Search saved information

Query collected records in the local Vault and keep the evidence needed to use the results.

Saved search is useful for finding information already collected from your apps. It uses read-only SQL. It does not accept a natural-language search prompt and does not query every connected provider in real time.

## Check what has been collected

```sh
zortex search --sql 'SELECT source, COUNT(*) AS records FROM z_records GROUP BY source ORDER BY source'
```

The result describes the records currently available in this Vault. A source with no rows may still have working live actions. Check [source coverage](/docs/vision/connectors/coverage) if expected material is missing.

## Search a title and body

This example finds up to ten records containing the text `website redesign`:

```sh
zortex search --json '{"sql":"SELECT id, source, source_id, title, substr(body, 1, 1200) AS excerpt FROM z_records WHERE title LIKE ? OR body LIKE ? LIMIT 10","params":["%website redesign%","%website redesign%"]}'
```

The `%` symbols make this a substring match. This is a literal text query, not semantic similarity ranking. Change the bound text rather than inserting arbitrary text into the SQL string. Use a small `LIMIT` while inspecting the results.

The rows carry `id`, `source`, and `source_id` so you can identify the evidence. The excerpt is intentionally shortened. Do not write a detailed conclusion from that excerpt if the rest of the record may change its meaning.

## Restrict a query to one source

```sh
zortex search --json '{"sql":"SELECT id, source, source_id, title FROM z_records WHERE source = ? AND (title LIKE ? OR body LIKE ?) LIMIT 10","params":["gmail","%website redesign%","%website redesign%"]}'
```

Use the source ID from your inventory. For precise account, date, or resource filtering, consult the documented tables and fields in the [SQL reference](/docs/vision/reference/sql). Do not assume every connector stores the same timestamp or account columns.

## Open the records you will rely on

Copy an actual returned record ID:

```sh
zortex search --json '{"sql":"SELECT id, source, source_id, title, body FROM z_records WHERE id = ? LIMIT 1","params":["<returned-record-id>"]}'
```

Check the body, its source, and any provider reference it contains. Preserve the source identity when taking notes or producing an answer. [Read live data and verify sources](/docs/vision/tools/read) covers completeness and current-state checks.

## Use the same query through MCP

```text
indra.search({
  "sql":"SELECT id, source, source_id, title FROM z_records WHERE source = ? LIMIT 5",
  "params":["gmail"]
})
```

Your agent can translate a request into bounded SQL, inspect the rows, and follow the evidence. The CLI and MCP use the same `sql` and optional `params` inputs.

## Interpret an empty or incomplete result

First remove unnecessary filters and check the source count. Then check the correct Vault, source/account, synchronization scope, and current connection state. If the question needs current provider data, use a [live action](/docs/vision/tools/actions). An empty local search is not proof that the provider contains no matching information.

A syntax or unavailable-column error needs a corrected query, not another sign-in. For large results, narrow the source and subject, return fewer columns, and page deliberately. Do not query credentials or private internal stores to work around an access limit.
