# Structured query syntax

> Multi-line query documents with term, intent, and hyde for explicit retrieval behavior.

Section: Reference  
Canonical: https://gno.sh/docs/syntax  
Markdown: https://gno.sh/docs/syntax.md

For complex queries, GNO supports a multi-line query document syntax on `gno query` and `gno ask`. Use typed lines to steer the retrieval pipeline without reaching for CLI flags.

## What this is

Structured query syntax is a small text format for telling GNO which parts of a question are exact terms, which parts describe intent, and which parts should act like a hypothetical ideal answer. It helps when a natural-language question is ambiguous or when your personal knowledge base uses inconsistent wording.

## Example

```
auth flow
term: "refresh token" -oauth1
intent: how token rotation works
hyde: Refresh tokens rotate on each use and previous tokens are invalidated.
```

## Rules

- Structured syntax is only activated for multi-line input.
- Blank lines are ignored.
- Recognized typed lines: `term:`, `intent:`, `hyde:`.
- At most one `hyde:` line is allowed per document.
- Unknown prefixes (e.g. `vector:`) are rejected.

## Base query resolution

Every query document needs a base query. GNO picks the base in this order:

1. Plain untyped lines joined together
2. Otherwise all `term:` lines joined together
3. Otherwise all `intent:` lines joined together

`hyde:` lines are expansion-only; they are not searched as terms.

## Supported surfaces

- CLI: `gno query`, `gno ask`
- REST: `/api/query`, `/api/ask`
- MCP: `gno_query`
- Web UI: Search and Ask text boxes
- SDK: `client.query(...)`, `client.ask(...)`

## CLI example

```
gno query $'auth flow\nterm: "refresh token"\nintent: token rotation'
```
