Skip to main content
Document Enrich stage showing collection joins and cross-reference lookups
The Document Enrich stage performs collection joins by looking up related documents from other Mixpeek collections. This enables cross-reference enrichment without external database calls.
Stage Category: ENRICH (Enriches documents)Transformation: N documents → N documents (with joined data added)

When to Use

When NOT to Use

Parameters

Join modes

The stage runs in one of two modes, chosen by whether retriever_id or retriever_config is set. Direct join (the default). The stage reads the value at source_field from each document and looks for a document in target_collection_id whose target_field has the same value. A document with no value at source_field is not looked up and passes through unchanged when allow_missing is true. Retriever join. The stage evaluates retriever_inputs for each document and runs the retriever named by retriever_id, or the inline retriever_config, with those inputs. Documents that produce identical inputs share a single retriever run. In an inline retriever_config, string stage parameters that contain {{DOC.field_name}} are filled in from the current document. source_field and target_field are not used in this mode. In both modes each document receives at most one match: the first document found, or the top result of the retriever. fields_to_merge, output_field, strategy, when and allow_missing apply the same way in both.

Merge strategies

  • enrich places the match under output_field. Without output_field, it merges the match into the document root and keeps existing fields unless the match has a field of the same name.
  • replace merges the match into the document root and overwrites fields of the same name. output_field is not used.
  • append adds the match to an array at output_field, or at enrichments when output_field is unset.

Configuration Examples

Output Schema

Single Document Join

Append Strategy

With strategy: "append", output_field holds an array and the match is added to it.

No Match Found

With allow_missing: true (the default) the document passes through unchanged and no output_field is added. With allow_missing: false the document is removed from the results.
When none of the checked documents match, the response also carries a warning that names the join. The stage metadata reports documents_checked, documents_enriched and documents_skipped.

Performance

Use fields_to_merge to reduce payload size. Documents that share the same retriever inputs run the retriever once, so keep retriever_inputs to the fields that matter.

Common Pipeline Patterns

Search + Author Enrichment

Product Search with Reviews

Hierarchical Category Enrichment

Error Handling

vs Other Enrichment Stages