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’sstages 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.
Feature search
Finds documents by vector similarity, keyword (BM25) match, or both. Each entry insearches 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.
Per-search options
Per-search options
Query by image, by a stored document, or with both
Query by image, by a stored document, or with both
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 and facet inside the search
Group and facet inside the search
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
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
Agent search
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
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
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
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
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
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
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 beforescore_threshold or before mixing scores from different stages.
score_normalize stage
Reduce stages
A reduce stage shrinks the list or collapses it into fewer, new documents. Several of them change whatdocuments holds, and each section says what you get back.
Limit
Keeps the firstlimit documents after skipping offset. It is the pipeline’s LIMIT ... OFFSET.
limit stage
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
score_normalize first if you must gate on them. Latency: under 1 ms.
Deduplicate
Removes duplicates by exact field values or by text similarity. Usefield for ids and URLs, content for near-identical text.
deduplicate stage
Sample
Picks a random, stratified or reservoir sample. Use it for review queues, evaluation sets, or a spread across categories.sample stage
Aggregate
Computes metrics over the documents, overall or per group. By default it returns no documents, and the rows are atstage_statistics.stages.<stage_name>.metadata.aggregations in the execute response.
Aggregation functions
Aggregation functions
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).More aggregate examples
More aggregate examples
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
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 theirstage_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
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
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 fromagentic_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
RAG prepare
Packs documents into an LLM context within a token budget and builds citations. It calls no LLM; feed its output tosummarize, llm_enrich or your own model call.
rag_prepare stage
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
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
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 parameterizedSELECT 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.
Join warehouse metrics onto results
Join warehouse metrics onto results
A creative library often keys a metrics table (spend, ROAS, thumb-stop rate) by A creative with no row gets
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
null. api_call sends one request per document, one after another.External web search
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
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 indocuments.
external_reverse_image stage
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
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
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
_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 areapply 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. Useoutput_schema to get structured fields such as entities, sentiment or a category.
llm_enrich stage
Classify
Labels each document with a classifier at query time. Set exactly one oftask (a hosted task), inference_name (a hosted label model) or feature_uri (your own classifier plugin).
classify stage
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
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 SQLLEFT JOIN. Join by a field match, or find the match with a retriever.
document_enrich stage
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
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 isWHERE, 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: avideos 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
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.
