E_AUTH_429. HydraDB combines both by default; this is called hybrid search. BM25 is the keyword-ranking method used in that combination.
Semantic vs keyword search
POST /query is the unified retrieval endpoint. Two parameters decide what runs:
typepicks the store:"knowledge"(Knowledge),"memory"(user-scoped Memories), or"all"(both from the same scope, merged and re-ranked together).query_bypicks the retrieval method:"hybrid"(semantic + BM25, the default) or"text"(BM25 only, withoperator: "or" | "and" | "phrase", default"or").
Why pure semantic search breaks
Pure vector search can miss important production constraints:- Exact identifiers such as
E_AUTH_429orpayments-worker-v4may be generalized away. - A project name can collide with a normal word, like
strawberrythe project vs strawberry the fruit. - Old and new documents can look equally relevant without recency or metadata signals.
- Different users can need different context for the same query.
- Relationship questions need graph context, not only similar text chunks.
query_by: "hybrid" inside the unified /query endpoint rather than as a separate pure-vector mode.
The alpha parameter
alpha controls the semantic versus BM25 keyword blend when query_by: "hybrid". Higher values lean semantic; lower values lean on keywords.
Start with the API default (
0.8; "auto" also resolves to 0.8) and tune from observed results. If users query for exact IDs and get loosely related content, lower alpha. If they ask broad conceptual questions and get sparse results, raise it. alpha applies only to query_by: "hybrid"; it is ignored for "text".
Query request example
metadata_filters are exact constraints that run before ranking and are re-checked after the matching passages are loaded. Use them whenever the query has a scope that should not be violated. Top-level keys match metadata and support equals, contains, and contains_any (no range or fuzzy match); nest under additional_metadata to filter free-form per-document fields. The example above uses one to keep retrieval inside the phoenix project.
More recipes
Technical lookup
Loweralpha when names, IDs, and literal strings matter.
Exact phrase query
Switch toquery_by: "text" with operator: "phrase" when a literal match is the point of the query.
Reading the response
POST /query returns ranked chunks and source metadata, not an answer. A typical application flow is:
- Call
POST /querywith the righttypeandquery_byfor the query. - Keep the chunks that are relevant enough for your use case.
- Format
chunk_content, source titles, and graph context into a prompt. - Ask your LLM to answer using only that context.
Related
- Query: full parameter reference and parallel query patterns
- Context Graphs: how graph context enriches retrieval
- Metadata: designing filterable schemas
- How to Use API Results: turning the response into an LLM prompt
