filter@v1 stages.
Filter Strategies
| Strategy | When to Use | Parameters |
|---|---|---|
structured | Fast field-based filtering using comparison operators | structured_filter (supports AND, OR, NOT, eq, lt, gte, in, etc.) |
text | Convert natural language descriptions into structured predicates | text_filter, optional target_fields |
llm | Ask an LLM to judge whether documents match free-form criteria | llm_filter (prompt, model, threshold, batch size) |
custom | Execute a bespoke Python expression (careful with performance) | function_code (stringified lambda) |
Filter Operators
| Operator | Description |
|---|---|
eq, ne, gt, gte, lt, lte | Comparison |
in, nin | Membership |
exists, is_null | Presence checks |
contains, starts_with, ends_with, regex | Text predicates |
AND, OR, NOT | Logical composition (nestable) |
false; set "case_sensitive": true on the filter payload when needed.
Where Filters Live
- Retriever Execution Payload
Add afiltersobject directly in the execute call. The filter runs before the stage pipeline, reducing the initial candidate set. - Filter Stage
Insertfilter@v1between other stages to operate on intermediate results (after KNN, before rerank, etc.).
LLM Filter Example
- Documents are grouped into batches and evaluated asynchronously.
- Stage statistics expose token usage and latency so you can monitor cost.
Best Practices
- Filter early to shrink the candidate set before expensive stages (rerank, joins, LLM transforms).
- Index frequently filtered fields using collection payload indexes to speed up structured filters.
- Mix strategies—use structured filters for hard constraints and LLM filters for fuzzy criteria.
- Avoid over-filtering by leaving room for semantic recall; reranking can handle final ordering.
- Use templates to drive filter values from query inputs, stage outputs, or runtime context.

