1. What it is
Metadata is structured data attached to knowledge and memories. It lets you narrow recall to a known scope before semantic retrieval runs. Use metadata when you already know a concrete attribute of the content you want back - for example:environment: "production"document_type: "runbook"compliance_framework: "SOC2"status: "published"
2. What it does
When you passmetadata_filters to recall, HydraDB uses those filters to narrow the candidate set before ranking retrieved chunks.
This gives you more predictable recall when the query needs to stay inside a known slice of data.
For example, this query:
3. When to use it
Use metadata filtering when:- The result must come from a known category, environment, customer tier, language, status, or document type.
- You need deterministic narrowing alongside semantic recall.
- You want to avoid mixing content from different operational scopes.
- You want to keep draft, archived, internal, or region-specific content out of a user-facing answer.
- Synonyms
- Partial matches
- Fuzzy intent
- Conceptual similarity
- Ranking preferences
- Range or contains-style operators
4. How it works
1. Define filterable fields
Filterable top-level metadata fields are defined in the tenant metadata schema. Plan filterable fields before ingestion. If your application needs to filter on a field, define it in the tenant metadata schema before writing data that depends on that filter, and enable matching for it.2. Attach metadata when writing data
Attach metadata when adding knowledge or memories. Use metadata for stable attributes that you expect to filter on later, such as:3. Filter during recall
Passmetadata_filters during recall to narrow the candidate set.
5. Key concepts
Tenant metadata schema
The tenant metadata schema defines which top-level metadata fields can be matched during recall. Use it for fields that your application will filter on repeatedly, such as:environmentlanguageregiondocument_typestatuscustomer_tier
tenant_metadata_schema examples, supported field types, and advanced configuration options, see Create Tenant API Reference.
enable_match
A metadata field must be match-enabled to be usable in metadata_filters.
If a field is stored but not match-enabled, do not rely on it for deterministic filtering.
metadata_filters
metadata_filters is the recall parameter used to apply deterministic filters.
Example:
metadata vs additional_metadata
HydraDB exposes two metadata fields on every source object. Both are filterable at recall, but via different keys in metadata_filters and with different performance characteristics:
metadata— schema-aligned tenant-level fields. Each key must be declared intenant_metadata_schemawithenable_match: trueat tenant creation. Filter via top-level keys inmetadata_filters. Pre-filtered in the vector store, so this is the fast path.additional_metadata— free-form document-level fields. Filter by nesting under theadditional_metadatakey insidemetadata_filters(canonical) ordocument_metadata(legacy alias). Applied post-retrieval, with the engine over-fetching (~3x) to compensate — slower than tenant-level filters.
6. Minimal working example
This example shows the full pattern:- Create a tenant with a filterable metadata field.
- Write content tagged with that metadata.
- Recall content matching that metadata.
1. Define filterable metadata
2. Attach metadata when writing content
3. Recall with metadata_filters
7. Recommended patterns
Published vs draft content
Use astatus field when your application has both draft and published content.
Language-specific recall
Use alanguage field when your tenant contains multilingual content.
Environment-specific recall
If environment-specific content intentionally exists in the same tenant scope, use anenvironment field to narrow recall.
Document-type filtering
Use adocument_type field when different source types should be retrieved differently.
8. Common mistakes
Filtering on fields that were not configured for matching.If a field is not declared and match-enabled, HydraDB ignores that filter. Plan filterable fields before ingestion so your filters actually narrow recall. Using metadata filters for fuzzy search.
Metadata filters are for structured constraints. Use semantic recall for fuzzy meaning, synonyms, or conceptual matches. Trying to use metadata as a tenant boundary.
Metadata narrows results inside a scope. It should not replace
tenant_id or sub_tenant_id for scoping customers, users, or workspaces.
Adding filterable fields too late.If your application needs deterministic filtering on a field, plan it early and declare it in the tenant metadata schema before ingestion. Confusing metadata fields across endpoints.
Metadata is always passed as plain JSON objects using the field names
metadata and additional_metadata. Check the relevant endpoint reference for which fields are supported.
Over-filtering.Too many filters can remove the chunk that would have answered the question. Start with the minimum hard constraints needed, then tune.
Related
- Recall - using
metadata_filtersduring retrieval - Memories - metadata fields on memory items
- Multi-Tenant Support - tenant and sub-tenant scoping
- Create Tenant API Reference - defining tenant metadata schema
- Full Recall API Reference - using metadata filters in recall