Skip to main content
POST
The single retrieval endpoint for everything. Use it any time you need to feed an LLM with grounded context, surface user preferences, or fetch chunks ranked by relevance. Three independent dimensions control behavior:
  • type picks what to query: "knowledge", "memory", or "all" (both, merged and re-ranked together).
  • query_by picks how to match: "hybrid" (semantic + BM25, the default) or "text" (BM25 only - pair with operator).
  • mode picks how to rank results: "fast" (single-pass, low-latency), "thinking" (expands query, reranks, and can include forceful-relation context), or "auto" (scores the query and routes to "fast" or "thinking" automatically, defaulting to "thinking" when the signal is inconclusive - the default if mode is omitted).
Read more about choosing the perfect mode for your use case here.
database and collection are the current field names (formerly tenant_id and sub_tenant_id). The old names remain accepted as deprecated aliases for full backward compatibility.

Querying multiple collections

Use collections when one query should fan out across multiple user, workspace, or team scopes. The field accepts either a list or a weighted object:
Equal weighting
Weighted ranking
A list gives every collection equal normalized weight. An object treats values as positive relative ranking weights with at most one decimal place and normalizes them server-side. You can send at most 100 collections. When max_results is omitted, HydraDB uses up to 10 results per collection, capped at 1000 fanout candidates before the final ranked response is shaped. When max_results is set, it is the final global response cap across the merged fanout result set.
Caching tip: collections list order is not semantically significant for fanout selection. Sort list values before constructing cache keys; for weighted objects, sort keys and keep weights at the documented one-decimal precision so equivalent calls share the same cache entry.

Transforming the response into LLM context

Use build_string / buildString from the SDK. It takes any POST /query result and returns a formatted plain string.

Common use-cases and their configurations

HydraDB scores the query before retrieval and routes it to "fast" or "thinking" - a query naming several distinct entities like this one is likely to route to "thinking". Use "auto" for traffic where query complexity varies call-to-call and you don’t want to hand-pick per request. This is also the default: an omitted mode field behaves exactly like mode: "auto". Set mode to "fast" or "thinking" explicitly if you want a deterministic pipeline instead.

Request body

Tuning heuristics.
  • alpha: start at 0.8. Lower toward 0.3–0.5 when the query contains literal tokens (error codes, SKUs, product names). Raise toward 0.9 for conceptual questions. Use “auto” when query shape varies.
  • recency_bias: leave at 0 for static reference material. Set 0.2–0.4 for mixed content, 0.6–0.8 for changelogs, news, or status updates.
  • max_results: start at 10. Drop to 5 for tight context windows; raise to 20 if you rerank downstream.

Decision matrix

For query_by: "hybrid":"auto"’s resolved pipeline isn’t reported back in the response, so budget latency as thinking-level in the worst case. Omitting mode behaves exactly like mode: "auto" - set it explicitly to "fast" or "thinking" if you want a deterministic pipeline instead.
metadata_filters are hard exact-match constraints applied before ranking and re-checked after hydration. The shape combines two filter scopes:
Multiple filters are ANDed. Range, contains, fuzzy, and OR operators are not supported in user-provided metadata_filters; run multiple queries or post-process client-side for those cases.
A zero-result query returns empty arrays/maps rather than an error, as shown in the Zero results tab.

Behavior notes

Default Behaviors
  • mode defaults to "auto". Omitting mode entirely behaves exactly like mode: "auto" - set it explicitly to "fast" or "thinking" if you want a deterministic pipeline.
  • graph_context is on by default. Set it to false if you only need ranked chunks and want to drop the graph slice from the response.
  • recency_bias is off by default. Defaults to 0.0 - no recency boost is applied unless you set it.
Important Considerations & Common Mistakes
  • query_forceful_relations requires mode to resolve to "thinking". In fast mode the flag is silently ignored. The server does not error or warn - your additional_context will simply be empty. Under mode: "auto" this depends on that request’s routing decision, not on what you asked for.
  • mode: "auto" overrides graph_context. Whatever you send for graph_context is replaced to match the resolved mode - true if auto escalates to thinking, false if it resolves to fast. This also applies when mode is omitted, since it defaults to "auto". Set graph_context explicitly only when calling "fast" or "thinking" directly.
  • Want a deterministic pipeline instead of automatic routing? Set mode explicitly to "fast" or "thinking" - an omitted mode field now defaults to "auto", not "fast".
  • Relation timestamp is a Unix epoch float here. In the graph_context slice returned by /query - and in the passthrough relations returned by List Documents with include_fields: ["relations"] - each relation’s timestamp is a Unix epoch value in seconds (a float, e.g. 1778573640.0). The dedicated Context Relations endpoint returns the same field as an ISO-8601 string instead. Normalize before comparing relation timestamps across endpoints.
  • Use the right metadata namespace. Top-level metadata_filters keys match metadata; free-form per-document fields must be nested under additional_metadata (document_metadata is only a legacy alias). Declare hot top-level filter fields in database_metadata_schema with enable_match: true.
  • Common mistakes. Check Ingestion Status for recently ingested documents before querying. If you omit collection, HydraDB queries the default collection; use List Collections to discover available IDs.

Errors

Common codes: 400 INVALID_PARAMETERS (empty query), 404 DATABASE_NOT_FOUND, 422 VALIDATION_ERROR, 500 INTERNAL_ERROR. See Error Responses for the full list.
Related Resources

Authorizations

Authorization
string
header
required

API key sent as a Bearer token: "Bearer prefix.secret"

Body

application/json

Unified query request

additional_context
string

Optional context string prepended to the query to improve retrieval relevance.

Example:

"The user is a senior engineer onboarding to the platform."

alpha
any

Weighting balance between dense and sparse retrieval in hybrid mode. "auto" lets HydraDB choose; a number from 0 (full BM25) to 1 (full dense) sets it explicitly.

collection
string

Collection scope. Defaults to the default collection when omitted. Formerly sub_tenant_id; the sub_tenant_id alias is still accepted (deprecated).

Example:

"team_docs"

collections

Preferred /query scope selector. Send either a list of collection IDs for equal normalized weighting, or an object mapping collection ID to a positive relative ranking weight with at most one decimal place. Do not send together with the deprecated sub_tenant_ids or sub_tenant_id.

Required array length: 1 - 100 elements
Example:
database
string

Database is the canonical v2 name for the tenant scope. TenantID is its deprecated alias and remains fully accepted. The TenantAliases middleware reconciles the two before binding, so TenantID is always populated and the handler reads it; Database/Collection are carried only for docs/OpenAPI.

Example:

"acme_corp"

graph_context
boolean

Whether to include graph context in the response. Defaults to true for /query when omitted.

Example:

true

graph_vector_prune
boolean

GraphVectorPrune switches the graph-connected-chunks lane from "fetch graph-selected chunks and let the fusion reranker sort them out" to "fetch a wider graph-selected candidate pool, then rank that pool by Milvus vector similarity, fully replacing the final chunk list." Works in either fast or thinking mode. Default false preserves existing behavior. Also gated server-side by a repo-level config flag (SearchService's graphVectorPruneEnabled) — if that flag is off, this is forced to false regardless of what the request sets, so a deployment can disable the mechanism without any client-side change.

Example:

true

graph_vector_prune_spacy_entities
boolean

GraphVectorPruneSpacyEntities: when GraphVectorPrune is also set, swaps the graph lane's entity-extraction source from the default LLM-based extractor to a local spaCy subprocess (faster, no network round trip, but a narrower/mismatched entity vocabulary versus the graph's own LLM-extracted node names). No-op if GraphVectorPrune is false (including when forced false by the server-level flag) or no spaCy extractor was configured at startup.

Example:

true

ids
string[]

IDs optionally scopes retrieval to specific source ids. The v2 wire field is ids (matching /context/list); empty means search the whole corpus. Applied as a Milvus source_id in [...] pre-filter that is preserved across the metadata zero-result retry, so a source-scoped search that matches nothing returns nothing rather than silently widening to the whole corpus.

Example:
max_results
integer

Maximum number of chunks to return.

Example:

10

metadata_filters
object

Filters results by source metadata. Top-level keys target tenant metadata (for example department, priority, active, or tags). Nested additional_metadata keys target document metadata. Values are exact-match scalars or arrays for set-equality/list-style filters.

Example:
mode
enum<string>
Available options:
fast,
thinking,
auto
Example:

"thinking"

Number of adjacent chunks to pull alongside each matched chunk for additional context.

Example:

3

operator
enum<string>
Available options:
or,
and,
phrase
Example:

"and"

query
string

Natural-language search query.

Example:

"Which mode does the user prefer?"

query_apps
boolean

Whether to include app-aware knowledge retrieval. Applies to knowledge hybrid queries.

Example:

true

query_by
enum<string>

Retrieval method to use for the query.

Available options:
hybrid,
text
Example:

"hybrid"

query_forceful_relations
boolean

Whether to force relation expansion for graph-aware query retrieval. Defaults to true when omitted.

Example:

true

recency_bias
number

Recency boost applied to ranking. 0 disables it; higher values favour more recent sources.

Example:

0.2

sub_tenant_id
string
deprecated

Deprecated for /query (since 2.0.1). Use collection for a single scope or collections for multiple. Backwards-compatible and will be removed in a future version. Do not send together with a multi-scope selector.

Example:

"sub_tenant_4567"

sub_tenant_ids
deprecated

Deprecated for /query (since 2.0.1). Use collections instead; it accepts the same list or weighted-object shape. Backwards-compatible and will be removed in a future version. Do not send together with collections.

Required array length: 1 - 100 elements
Example:
tenant_id
string
deprecated

deprecated: use database

Example:

"tenant_1234"

type
enum<string>

Corpus to query: knowledge, memory, or all.

Available options:
knowledge,
memory,
all

Response

OK

data
object
Example:
error
object

Error message, empty string on success.

Example:
meta
object
Example:
success
boolean

Whether the request succeeded.

Example:

true