Skip to main content
A retriever runs a list of stages in order. Each stage takes the documents from the stage before it and passes on a new list. This page lists every stage by category, then gives each one a section with its parameters and an example. GET /v1/retrievers/stages returns every stage’s full parameter schema (List available retriever stages). Put cheap stages first. A filter or limit before rerank or an LLM stage cuts the documents those slow stages process.

Stage object

Every stage in a retriever’s stages array has the same shape:
Stage object with every optional key
Parameters accept {{INPUT.*}}, {{DOC.*}}, {{CONTEXT.*}} and {{STAGE.*}} templates (see Stages and templates). LLM stages. llm_filter, llm_enrich, summarize, agent_search and agentic_enrich take provider (openai, google, anthropic, typesafe) and model_name. To use your own provider key, store it with POST /v1/organizations/secrets and set api_key to {{secrets.your_secret_name}}. llm_filter and llm_enrich refuse a run that sends them more than max_candidates documents (default 10, at most 50), before any model call.

Filter stages

A filter stage keeps a subset of documents with the same schema. feature_search and attribute_filter can also run first and read documents from the collections. Finds documents by vector similarity, keyword (BM25) match, or both. Each entry in searches queries one feature index, and the stage fuses the hits into one ranked list. Use it as the first stage of almost every retriever.
feature_search stage
pre_filters sits beside parameters inside config, and the vector store applies it during the search, so top_k counts matching documents. Filtered fields need payload indexes. A wrong feature_uri returns an error listing the available_feature_uris for your collections. Latency: 10 to 50 ms for one search, 20 to 80 ms with fusion.
Each entry’s query picks its own input_mode, so one stage can fuse a text search with an image search. content embeds a URL or base64 file with the index’s extractor; document reuses the vectors a stored document already has, with no inference.
feature_search with text, image and document queries
group_by groups hits in the vector store by a field such as source_object_id. It takes field, max_per_group (default 1), limit (default 25 groups, overrides final_top_k) and output_mode (first, all, flatten).facets returns value counts per field alongside the hits. Each entry is {"key": "metadata.category", "limit": 10, "exact": false}, and the field needs a keyword index. Facets count under pre_filters only.

Attribute filter

Keeps documents whose fields match conditions. After a search it filters the documents in memory. As the first stage it reads matching documents straight from the collections, with no embeddings needed.
attribute_filter stage
When a first-stage scan stops with matches left, the response carries a warning and a first_stage_scan_documents entry in limits. Raise max_scan_documents when a later group or aggregate needs every match. Latency: 5 to 20 ms.

LLM filter

Sends each document to an LLM with your criteria and keeps the ones it approves. Use it for judgments a field cannot express, such as tone or topic, after a search has narrowed the set.
llm_filter stage
Kept documents come back unchanged. Latency: 200 to 500 ms per batch, about 100 tokens per document. Runs an LLM reasoning loop that calls other stages as tools, deciding at each turn what to search or filter next. Use it for multi-hop questions where you cannot fix the pipeline in advance.
agent_search stage
cluster_navigation walks a cluster hierarchy top-down with a beam search over the centroid documents a cluster run writes. Set cluster_navigation.centroid_collection_ids to that run’s output collection. Latency: 2 to 30 s, depending on iterations and the stages called. Cost is the LLM calls plus each called stage.

Query expand

Asks an LLM for variations of the query, runs a feature search for each, and fuses the results. Use it to raise recall on short or ambiguous queries.
query_expand stage
Latency: 300 to 800 ms: one LLM call plus num_expansions + 1 searches run concurrently.

Sort stages

A sort stage returns the same documents in a new order. mmr and rerank can also trim the list with top_k.

Sort relevance

Reorders documents by a score field, highest first by default. Use it to restore relevance order after a stage that changed the order, or to order by a score another stage wrote.
sort_relevance stage
The stage never computes similarity. feature_address and use_query_embedding have no effect, and a retriever that sets use_query_embedding is refused with 422 from 2026-11-02. Latency: under 5 ms.

Sort attribute

Orders documents by a field value such as price, date or rating. score_boosts adds weighted terms to the score first, so you can blend relevance with popularity or recency.
sort_attribute stage
A recency boost needs half_life_days (or half_life_field). A match boost needs a condition in the attribute_filter conditions form. Latency: under 5 ms.

MMR

Maximal Marginal Relevance picks documents that are relevant and unlike the ones already picked. Use it to stop near-duplicates from filling the top of the list.
mmr stage
The stage writes each document’s MMR score to scores.mmr. diversity_features weights several embeddings together. Latency: 10 to 50 ms, no model calls.

Rerank

Scores each candidate against the query with a cross-encoder or a decision model, then reorders. Use it when the top few results must be right and you can afford seconds.
rerank stage
The score goes to scores.rerank; score keeps the retrieval value. If the deployment does not serve the model, saving the retriever returns 422 with details.served_alternatives. Latency: measured p50 3.26 s for BAAI__bge_reranker_v2_m3 on a production pipeline, about 3 s per document at 0.5 CPU. Cost grows with max_candidates, so keep it small. On 100 SciFact claims, Jev over the top 30 raised nDCG@10 from 0.817 to 0.880 at 669 ms per query.

Maxsim rerank

Rescores candidates with late interaction (ColBERT MaxSim): each query token matches its closest document token, and the matches are summed. Use it after a fast dense search to sharpen the order.
maxsim_rerank stage
A collection runs one extractor, so dense search plus ColBERT needs two collections over one bucket: search the text one, rerank with match_on: root_object_id. Stage metadata reports candidates, scored and missing_tokens.

Score normalize

Rescales scores to a common range so you can compare or threshold them. Use it before score_threshold or before mixing scores from different stages.
score_normalize stage
Latency: under 1 ms.

Reduce stages

A reduce stage shrinks the list or collapses it into fewer, new documents. Several of them change what documents holds, and each section says what you get back.

Limit

Keeps the first limit documents after skipping offset. It is the pipeline’s LIMIT ... OFFSET.
limit stage
For pages a user clicks through, use the execute request’s pagination instead (see Retrievers). Latency: under 1 ms.

Score threshold

Drops every document whose score fails an absolute bar. When nothing clears it, documents is empty and the stage sets all_below_threshold, so your UI can show “no good results”.
score_threshold stage
Threshold a calibrated score such as a rerank probability. Raw vector scores shift between queries; run score_normalize first if you must gate on them. Latency: under 1 ms.

Deduplicate

Removes duplicates by exact field values or by text similarity. Use field for ids and URLs, content for near-identical text.
deduplicate stage
Latency: under 5 ms by field, 10 to 100 ms by content.

Sample

Picks a random, stratified or reservoir sample. Use it for review queues, evaluation sets, or a spread across categories.
sample stage
Latency: under 5 ms.

Aggregate

Computes metrics over the documents, overall or per group. By default it returns no documents, and the rows are at stage_statistics.stages.<stage_name>.metadata.aggregations in the execute response.
Every function except count reads field. co_occurrence and correlation also read field_b; percentile takes percentile_value (0 to 100, default 50); frequency and co_occurrence take top_k (1 to 100, default 10).
Each item is the config of an aggregate stage.
aggregate config values
aggregate stage
emit_groups and include_documents cannot be combined. Latency: 5 to 50 ms.

Temporal

Buckets documents into time windows and computes metrics per window, with optional drift detection between windows. Use it for trend lines and spike alerts over search results.
temporal stage
Latency: 5 to 50 ms.

Summarize

Sends the documents to an LLM and returns a summary document, or one per group. Use it to answer a question from the retrieved content.
summarize stage
documents holds the summary documents, with source_document_ids for citations. Latency: 500 to 2,000 ms.

Moment group

Merges matching video segments that sit close in time into moments with a start and end, per video. Use it to return “minute 3:10 to 3:42” instead of a list of frames.
moment_group stage
query_chunks exists only for file-input queries with preprocessing. Fields ending _time, _s, _sec or _seconds are read as seconds; moments are always in milliseconds. Latency: 5 to 50 ms.

Group stages

Group stages bucket documents. They are reduce stages in the API, so their stage_type is reduce.

Group by

Groups documents that share a field value, for example every chunk of one video or every product of one brand.
group_by stage
To group inside the vector store before results leave it, use group_by on feature_search. position_caps limits how many groups of one kind lead a page. Latency: 5 to 20 ms.

Cluster

Clusters the documents by embedding similarity at query time, to show themes in a result set. For clusters over a whole collection, use Clusters.
cluster stage
Latency: 50 to 200 ms.

Apply stages

An apply stage reshapes documents, expands them, or adds data from outside the collection. The enrich stages below are apply stages in the API too, apart from agentic_enrich and code_execution.

JSON transform

Renders a Jinja2 template per document and replaces the document with the resulting JSON. Use it to shape output for a frontend or an external API.
json_transform stage
Latency: under 1 ms per document.

RAG prepare

Packs documents into an LLM context within a token budget and builds citations. It calls no LLM; feed its output to summarize, llm_enrich or your own model call.
rag_prepare stage
Token counts use the cl100k_base tokenizer by default. Latency: under 10 ms.

Unwind

Turns each element of an array field into its own document, like MongoDB’s $unwind. Use it to rank tags, line items or detected objects one by one.
unwind stage
Latency: under 5 ms.

API call

Calls an HTTP API per document and stores the response on it. Use it to join live data such as stock, pricing or CRM fields.
api_call stage
Create the secret first with POST /v1/organizations/secrets. when takes a filter tree so only matching documents make the call. Latency: 100 to 500 ms per request.

SQL lookup

Runs a parameterized SELECT against a PostgreSQL connection per document and stores the rows on it.
sql_lookup stage
A connection to a provider other than PostgreSQL fails with Connection does not support SQL queries; reach a warehouse through api_call. Latency: 10 to 100 ms.
A creative library often keys a metrics table (spend, ROAS, thumb-stop rate) by creative_id. Use sql_lookup when the table is in PostgreSQL, and api_call against an HTTP endpoint that runs the query when it is in Snowflake or another warehouse. Both run after the search and add a warehouse_metrics field to each document. A joined value cannot rank results; to rank by ROAS, ingest it as document data.
sql_lookup from PostgreSQL
api_call to another warehouse
A creative with no row gets null. api_call sends one request per document, one after another.
Adds web results from Exa to the documents you already have. Use it when your collections may lack fresh or outside content.
external_web_search stage
Latency: 200 to 500 ms.

External reverse image

Appends open-web matches for a query image from Google Lens through SerpAPI, after your own image matches. Your earlier results always stay in documents.
external_reverse_image stage
The deployment needs a SerpAPI key. Without one, or when the call fails, the stage returns your earlier results with a warning.

Web scrape

Fetches the page at a URL, from a document field or the input, and stores its main text. It can also crawl links from a seed URL.
web_scrape stage
Latency: 500 to 5,000 ms per page.

Cross compare

Compares each source document’s elements with a reference collection through a cascade of match tiers (exact, fuzzy, vector) and labels each match. Use it for drift, duplicate and compliance checks, for example a product video against its documentation.
cross_compare stage
Each finding carries match_tier, match_score, classification and confidence. Latency: 50 to 1,500 ms, depending on tiers.

Traverse edge

Moves from the current documents to related ones. It follows typed object edges, walks lineage up to the document each hit came from, or keeps hits whose time spans overlap spans in another collection.
traverse_edge stage
Lineage mode reads each document’s _internal.lineage.source_document_id, so you can search a segment collection and return whole videos. Overlap mode takes spans, target_spans, min_overlap_seconds and max_targets (default 5000); a join over max_targets is refused with 400, and on_error: "skip" is refused at create. The stage calls no model and adds no credits.

Enrich stages

An enrich stage adds fields to each document from a model, a taxonomy, another collection or your own code. Most of them are apply stages in the API; the stage_type in each example is the one the API infers.

LLM enrich

Sends each document to an LLM with your prompt and writes the answer to a field. Use output_schema to get structured fields such as entities, sentiment or a category.
llm_enrich stage
Cost: 2 credits per document in the results. Explain prices the stage before you run it. Latency: 300 to 800 ms per batch; at the stage’s ceiling (25,000 ms by default) unanswered calls are cancelled and the answered ones kept.

Classify

Labels each document with a classifier at query time. Set exactly one of task (a hosted task), inference_name (a hosted label model) or feature_uri (your own classifier plugin).
classify stage
The nsfw task returns nsfw_score (0 to 1), label and is_nsfw, and flags at nsfw_threshold (default 0.7). It runs on CPU.

Taxonomy enrich

Matches each document against a taxonomy at query time and writes the best nodes onto it. Use it when labels must reflect the current taxonomy without reprocessing the collection.
taxonomy_enrich stage
Assignments land as flat fields named from the taxonomy id without its tax_ prefix, for example _taxonomy_product_categories_label and _taxonomy_product_categories_score. A document with no assignment over min_score passes through unchanged. Latency: 20 to 100 ms.

Document enrich

Joins each document with a document from another collection, like a SQL LEFT JOIN. Join by a field match, or find the match with a retriever.
document_enrich stage
Latency: 5 to 20 ms per document for a field join.

Agentic enrich

Runs a multi-turn agent per document that can load taxonomy categories, look up already-labeled examples and analyze media before it writes a structured answer. Use it for labels a single prompt gets wrong, such as IAB categories for video.
agentic_enrich stage
self_consistency runs up to 5 evaluations and votes; escalation re-runs low-agreement documents on a larger model. Latency: 2 to 30 s per document.

Code execution

Runs your Python, TypeScript or JavaScript in a sandbox over the documents and merges the result into each one. Use it for logic no other stage expresses.
code_execution stage
Output is capped at max_output_size (default 100 KB, up to 1 MB). Latency: 5 to 50 ms per document.

Pipeline patterns

Stage categories map to SQL clauses: filter is WHERE, sort is ORDER BY, reduce is LIMIT and GROUP BY, enrich is JOIN, and apply is SELECT. Most pipelines follow one of these shapes. There is no stage that blends several score fields with weights. Use sort_attribute with score_boosts to add weighted terms to score, or score_normalize and then sort on one field.

Question answering pipeline

RAG retriever stages

Search segments, return whole videos

Split each video into layers, each its own collection: a videos layer with split_method: "whole" and a scenes layer with split_method: "scene". Embed only the layer you search. Search scenes, then climb lineage to videos. Fifty scene hits from 12 videos return 12 documents, each scored by its best scene, with the scenes in _evidence (start_time and end_time give the moment).
Scene search that returns parent videos
A scene that cannot reach videos is dropped, counted in stage_statistics.stages.whole_videos.metadata, and reported in warnings. A feature search over a layer with no vector index returns 400 naming the collection. To read a document’s parent or children outside a retriever, use the documents API’s expand (parent, ancestors, root_object, children), described in Collections and features. Deployable pipelines for these patterns are in Templates.