Metadata Filtering#
ZeusDB supports rich metadata with full type fidelity. This means your metadata preserves the original Python data types (integers stay integers, floats stay floats, etc.) and enables powerful filtering capabilities.
Supported Types#
The following Python types are supported for metadata and preserved during filtering and retrieval.
Type |
Python Example |
Stored As |
Notes |
|---|---|---|---|
String |
|
|
Text data, IDs, categories |
Integer |
|
|
Counts, years, IDs |
Float |
|
|
Ratings, prices, scores |
Boolean |
|
|
Flags, status indicators |
Null |
|
|
Missing/empty values |
Array |
|
|
Tags, categories, lists |
Nested Object |
|
|
Structured data |
Filter Operators Reference#
These operators can be used in metadata filters:
Operator |
Usage |
Example |
Description |
|---|---|---|---|
Direct equality |
|
|
Exact equality for any type |
|
|
|
Greater than (numeric) |
|
|
|
Greater than or equal (numeric) |
|
|
|
Less than (numeric) |
|
|
|
Less than or equal (numeric) |
|
|
|
String contains substring or array contains value |
|
|
|
String starts with substring |
|
|
|
String ends with substring |
|
|
|
Value is in the provided array |
Practical Filter Examples#
Below are common real-world examples of how to apply metadata filters using ZeusDB’s metadata filtering:
Example 1 - Find high-quality recent documents
filter = {
"published": True,
"rating": {"gte": 4.0},
"year": {"gte": 2024}
}
results = index.search(vector=query_embedding, filter=filter, top_k=5)
Example 2 - Find documents by specific authors
filter = {"author": {"in": ["Alice", "Bob", "Charlie"]}}
results = index.search(vector=query_embedding, filter=filter, top_k=5)
Example 3 - Find AI-related content
filter = {"tags": {"contains": "ai"}}
results = index.search(vector=query_embedding, filter=filter, top_k=5)
Example 4 - Find documents in price range
filter = {"price": {"gte": 20.0, "lte": 40.0}}
results = index.search(vector=query_embedding, filter=filter, top_k=5)
Example 5 - Find documents with specific file types
filter = {"filename": {"endswith": ".pdf"}}
results = index.search(vector=query_embedding, filter=filter, top_k=5)