---
title: "Query Collection"
method: POST
path: "/v2/collections/{collection_name}/query"
tags: ["query"]
---

# Query Collection

`POST /v2/collections/{collection_name}/query`

Execute the v2 File Search endpoint against a collection. Returns retrieved chunks in search_results with content fields.

## Path parameters

- `collection_name` string, required

## Request body

- QueryRequestV2 — Request body for v2 compatibility File Search. Returns retrieved chunks and does not generate an LLM answer.
  - `query` string, required — Natural-language search query.
  - `top_k` integer, nullable — Maximum number of search results to return.
  - `metadata_filter` object, nullable — Filter expression for indexed document metadata. Supports $eq, $ne, $gt, $gte, $lt, $lte, $in, $nin, $and, and $or.
  - `include_archived` boolean — Include chunks archived by a sync `archive` deletion policy. Archived content is excluded from search by default; set true to surface it.
  - `rerank` union — Rerank retrieved candidates before returning the top results (adds roughly 200 ms). Boolean form uses the defaults: voyage-rerank-2.5 over a pool of `limit` x 3 candidates. Object form tunes reranking — see RerankOptions. Multimodal collections default to reranking; an explicit `false` (or `{"enabled": false}`) opts out and returns a warning noting reduced cross-modal ranking quality. On v2, the deprecated `inference=true` path honours only the enabled/disabled state; the tuning fields apply to retrieval queries.
    - boolean
    - RerankOptions — Object form of the `rerank` parameter. The boolean form stays valid: `true` is equivalent to sending this object with every field at its default.
      - `enabled` boolean — Whether to rerank. Sending the object without this field means enabled — the object form exists to tune reranking.
      - `candidate_limit` integer, nullable — How many fused retrieval candidates are fetched and reranked before the top `limit` results are returned. Defaults to `limit` x 3 (the measured configuration). Must be >= `limit`; capped at 200. Larger pools can lift recall on corpora with many near-duplicate documents, at the cost of rerank latency.
      - `model` string, nullable — Reranker model. One of `voyage-rerank-2.5` (default) or `gemini-2.5-flash`; the family aliases `voyage` and `gemini` are accepted. Unknown values return a 400 listing the allowed set.
  - `include_bbox` boolean, nullable — Legacy v2 layout option retained for clients that already depend on bounding boxes.
  - `semantic_ratio` number, double — Balance between semantic and keyword retrieval. Captain searches both ways at once: keyword (sparse, BM25) matches the words in the query, semantic (dense vector) matches its meaning. 0.0 is keyword only, 1.0 is semantic only, and 0.5 (the default) weighs them equally. Lower it for corpora full of exact terms such as part numbers or error codes; raise it when callers phrase questions in their own words. Between the endpoints both searches run, so a result found only by the down-weighted side still appears, just lower. The endpoints skip the other search entirely: 0.0 also skips embedding the query, making it the fastest option, though queries using `boost` and collections holding images, video, or audio keep vector search running. See the Advanced Querying guide for more.

## Response `200`

Successful Response

- QueryResponseV2 — v2 compatibility File Search response. Returns search_results with content fields.
  - `success` boolean, required
  - `query` string, required
  - `search_results` FileSearchResult[], required
    - `score` number, double, required
    - `content` string, required — Retrieved chunk text. v3 uses text instead.
    - `document_id` string, nullable
    - `filename` string, nullable
    - `uri` string, nullable
    - `chunk_index` integer, nullable
    - `metadata` object, nullable
    - `rerank_score` number, double, nullable
  - `total_results` integer, required
  - `top_k` integer, required
  - `warnings` string[], nullable
  - `tokens_used` object, nullable
  - `execution_time_ms` integer, nullable
  - `request_id` string, nullable
  - `token_balance` TokenBalance
    - `credit_limit` integer, required
    - `total_used` integer, required
    - `remaining` integer, required
    - `unlimited` boolean

---

[API](https://skmtc.dev/runcaptain/apis/api-reference.md) · [All operations](https://skmtc.dev/runcaptain/apis/api-reference/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/runcaptain/api-reference/revisions/fe4649e3f4aa/schema)
