Query - v3
Search indexed files and return source chunks with optional document, metadata, region (bounding boxes), relation, and related chunk context.
Compared with v2: this response uses results[].text, supports explicit include controls, and returns structured rerank details.
Filter keys are top-level field names. Never nest them under metadata or custom_metadata. Use {"policy_area": "payments"}, not {"custom_metadata": {"policy_area": "payments"}}. Operators are $-prefixed ($gte, not gte). See the Advanced Querying guide for the full filter reference.
Path parameters
Request
This endpoint expects an object.
Natural-language search query.
1-100Defaults to 10Maximum number of ranked chunks to return.
Document metadata filter expression. Keys are top-level field names, never nested under metadata or custom_metadata. A bare value is an implicit $eq ({"policy_area": "payments"}). Supported operators: $eq (=), $ne (≠), $gt (>), $gte (≥), $lt (<), $lte (≤), $in, $nin, and the logical $and and $or. $in and $nin take a list; every other operator takes a scalar. Max nesting depth is 10. To scope a query to specific documents, filter on file_id with $in. See the Advanced Querying guide for more.
falseRerank 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.
Controls which optional result objects are included in the response.
Optional relation type filter when include.relations or include.related_chunks is enabled.
outgoingWhich graph edge direction to include for relation context.
outgoingincomingbothLayout roles to drop from results: body, table, heading, page_header, page_footer, footnote, figure. Useful for removing repeated page furniture such as running headers and footnotes. Applied during retrieval, before reranking, so excluded chunks never occupy a result slot. Chunks with no layout label always pass. Unknown values return a 400.
Optional metadata-based ranking: a list of up to 10 boost rules, each naming some of your own custom_metadata and how much to favour the chunks carrying it. Use it when a chunk is the right answer but does not match the query’s wording, for example one a reviewer tagged as the answer to this question, or one your application already cited earlier in a conversation. Each rule both retrieves chunks carrying that metadata and multiplies their retrieval score by weight. With reranking on the reranker still decides the final order unless a rule sets reserve. Omit the field entirely and retrieval is unchanged. See the Advanced Search guide for choosing a weight.
0-1Defaults to 0.5Balance 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.
1-100Cap on how many chunks any single document may occupy in results. Ranking is unchanged: the same ranked chunks come back, minus a document’s surplus beyond the cap, backfilled with the next best chunks from other documents so limit results still come back whenever the ranked pool has them. The cap is applied inside retrieval itself, so the candidate pool spans many documents rather than being thinned after the fact. Omitted (the default) applies no cap. The two numbers compose: limit = N x K returns up to N documents with up to K chunks each, in document-rank order, and each result’s document object (include.document, on by default) carries the document’s id, filename, and source. For the five most relevant documents, send limit: 5 with max_chunks_per_document: 1.
Response
Query response.
Echo of the submitted query.
Retrieved source chunks sorted by final retrieval score.
Number of results returned in this response.
Result limit applied to the request.
Whether reranking was applied and why.
Always-on query processing timing, including successful empty results. Stage offsets share one monotonic origin; overlapping durations must not be summed.
Non-fatal notices about the request or response, such as forced reranking for multimodal collections.
Compatibility alias for timing.total_ms. Prefer timing.total_ms for new integrations.
Request identifier for support and trace lookup.
Id of this query in your history. Fetch it back with GET /v2/queries/{query_id}. Present when the query was stored (completed, non-streamed queries).
[]The layout roles this query excluded, echoed back so a caller can confirm what the server applied. Empty when none were requested.
[]The boost rules this query applied, each with matched, in_pool, and on_page counts. Always present; empty when no boost was sent.
0.5The semantic/keyword balance applied to this query. Always present; 0.5 when the request did not set one.
Errors
import requests
BASE_URL = "https://api.filesearch.dev"
API_KEY = "your_api_key"
COLLECTION_NAME = "my_documents"
response = requests.post(
f"{BASE_URL}/v3/collections/{COLLECTION_NAME}/query",
headers={
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
},
json={
"query": "payment authorization requirements",
"limit": 3,
},
timeout=60.0,
)
for result in response.json()["results"]:
print(result["chunk_id"], round(result["score"], 4))
print(result["text"][:200]){
"query": "payment authorization requirements",
"results": [
{
"chunk_id": "f4a91c7e8b2d4a0c9e6f13b5a8d02744:0",
"score": 0.09523809523809523,
"text": "# Payment authorization form\n\nI authorize the merchant to charge the card on file for approved purchases.\n\nAmount authorized: <empty>\nCardholder email: <empty>\nProduct or service: <empty>\n\n## Card information\n\nCard type:\n[ ] Visa\n[ ] Mastercard\n[ ] American Express\n[ ] Other <empty>\n\n## Recurring payments\n\nCharge frequency: <empty>\nPayment amount: <empty>\nCancellation terms: <empty>",
"modality": "pdf",
"match_sources": [
"content_embedding",
"keyword",
"ocr"
],
"document": {
"id": "f4a91c7e8b2d4a0c9e6f13b5a8d02744",
"filename": "payment-authorization-form.pdf",
"source": {
"type": "file",
"uri": "captain://org_example/users/user_example/collections/customer_forms/payment-authorization-form.pdf",
"mime_type": null
}
},
"location": {
"page_start": 1,
"page_end": 1,
"chunk_index": 0,
"parent_chunk_index": 0,
"start_seconds": null,
"end_seconds": null,
"sheet_name": null,
"row_start": null,
"row_end": null,
"col_start": null,
"col_end": null
},
"media": null,
"metadata": {
"vectorScore": 0.42747492,
"bm25Score": 2.2132137,
"rrfScore": 0.09523809523809523,
"pageStart": 1,
"pageEnd": 1
},
"custom_metadata": {
"document_type": "authorization_form",
"review_status": "approved"
},
"rerank_score": null,
"boost": null
}
],
"total_results": 1,
"limit": 3,
"rerank": {
"used": false,
"reason": "disabled",
"model": null,
"candidate_limit": null
},
"timing": {
"stages": [
{
"name": "preparation",
"start_ms": 0,
"duration_ms": 13
},
{
"name": "embedding",
"start_ms": 13,
"duration_ms": 37
},
{
"name": "retrieval",
"start_ms": 50,
"duration_ms": 22
},
{
"name": "fusion",
"start_ms": 72,
"duration_ms": 1
},
{
"name": "hydration",
"start_ms": 73,
"duration_ms": 113
}
],
"total_ms": 186
},
"warnings": [],
"execution_time_ms": 186,
"request_id": "req_1787610044_2c8f41ab",
"query_id": "019a0e2a-7b31-7c4e-9d2f-3a8c1e5b6f90",
"exclude_chunk_types": [],
"boost": []
}