---
title: "POST /api/v1/{context_id}/documents/query"
method: POST
path: "/api/v1/{context_id}/documents/query"
---

# POST /api/v1/{context_id}/documents/query

`POST /api/v1/{context_id}/documents/query`

Runs a top-k semantic query over the Layer 0 chunks

## Path parameters

- `context_id` string, required

## Request body

- QueryRequestJson
  - `decomposeQuery` boolean, nullable — W5b: opt into sub-question decomposition for this query. The caller fans out to one retrieval per sub-question and RRF-merges the result lists. Like `use_hyde`, requires the Context to have an LLM provider attached.
  - `expandGraph` boolean
  - `filter` QueryFilter
    - `documentIds` string[]
    - `mimeType` string[]
  - `graphAlpha` number, float
  - `graphDepth` integer
  - `graphEdges` GraphEdgeKind[]
  - `k` integer — Max hits to return (default 10, max 50).
  - `location` DocGeoFilterJson — Phase 6.5 — geographic filter on `/documents/query`. Mirrors the shape on the memory `/query` endpoint.
    - `near` DocGeoNearJson
      - `lat` number, double, required
      - `lng` number, double, required
      - `radiusKm` number, double, required
    - `within` string, nullable
  - `mode` 'hybrid' | 'vector' | 'bm25' | 'hybrid_graph' — Chunk query mode: vector-only, BM25-only, hybrid RRF, or hybrid plus graph-density re-rank.
  - `query` string, required
  - `rrfK` number, float
  - `threshold` number, float
  - `useHyde` boolean, nullable — W5a: opt into HyDE (Hypothetical Document Embeddings) for this query. Requires the Context to have an LLM provider attached; callers without one should leave this `false`. Defaults to `false` so existing agents see the same vector-only behaviour.
  - `useReranker` boolean, nullable — W5c: opt into cross-encoder reranking of the top-K. Requires the server to have a `Reranker` provider attached. Off by default; takes effect after the store returns results so it composes naturally with HyDE / decomposition / hybrid graph.
  - `vectorWeight` number, float

## Response `200`

- QueryResponseJson
  - `queryMs` integer, required
  - `results` QueryHitJson[], required
    - `chunk` QueryHitChunkJson, required
      - `charEnd` integer, required
      - `charStart` integer, required
      - `document` string, required
      - `id` string, required
      - `position` integer, required
      - `section` string, nullable
      - `text` string, required
    - `document` QueryHitDocumentJson, required
      - `id` string, required
      - `source` string, required
      - `title` string, required
    - `graphEvidence` GraphEvidenceJson[], nullable
      - `edgeKind` 'knowledge_has_keyword' | 'section_match' | 'document_link' | 'document_summary' | 'hybrid_graph', required — Graph edge kinds used by [`QueryRequest::graph_edges`] for HybridGraph re-ranking.
      - `neighbourLabel` string, required
      - `weight` number, float, required
    - `graphExpansion` unknown
    - `score` number, float, required

## Other responses

- `400` — Invalid request
- `401` — Unauthorized
- `422` — Invalid context id
- `500` — Unexpected error

---

[API](https://skmtc.net/surrealdb/apis/spectron.md) · [All operations](https://skmtc.net/surrealdb/apis/spectron/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/surrealdb/spectron/versions/52b41ab517b6/schema)
