UserScope, so you can define a filter once and reuse it everywhere.
Prefer server-side filters over client-side post-processing. You’ll reduce bandwidth, improve performance, and keep behavior consistent between endpoints.
Where Filters Apply
You can passfilters (or document_filters) to:
- Retrieval endpoints:
retrieve_chunks,retrieve_docs,query,query_documentingestion options. - Listing/management:
list_documents, document/folder analytics, chat history, and anywhere an SDK method exposes afiltersargument.
Quick Start
Typed Metadata
Typed comparisons (numbers, decimals, dates, datetimes) rely onmetadata_types. Supply the per-field hints during ingest or metadata updates:
DateTime and Timezone Behavior
Morphik preserves your timezone format exactly as provided:
SDK Type Reconstruction: When you retrieve a
Document via the Python SDK, datetime/date/decimal values in metadata are automatically reconstructed to their Python types using the metadata_types hints. This means you get back what you put in:
Mixed Timezone Formats
Morphik handles mixed formats correctly - filtering and comparisons work even if some documents have naive datetimes and others have timezone-aware ones:Implicit vs Explicit Syntax
- Implicit equality – Bare key/value pairs (
{"status": "active"}) use JSON containment and are ideal for simple matching. They also check whether an array contains the value. - Explicit operators – Wrap a field in an operator object to unlock typed comparisons, set logic, regex, substring checks, etc. (
{"status": {"$ne": "archived"}}).
Operator Reference
Equality & Comparison
Set Membership
Type & Existence
String & Pattern Matching
Logical Composition
Mix logical operators freely with field-level operators for complex expressions.
Common Patterns
Current Window Between Start/End
Folder/User Scope plus Metadata
Array Membership & Substring
Troubleshooting
- “Unsupported metadata filter operator …” – Double-check spelling and operand type (lists for
$in, non-empty arrays for$and, etc.). - “Metadata field … expects type …” – The server couldn’t coerce the operand to the declared type. Ensure numbers/dates are valid JSON scalars or native Python types before serialization.
- Range query returns nothing – Confirm the target documents were ingested/updated with the corresponding
metadata_types. Re-ingest or callupdate_document_metadatawith the proper type hints if necessary.
founders@morphik.ai or on Discord.
