The Deduplicate stage removes duplicate documents from the result set based on exact field matching or content similarity. This is analogous to SQL’s DISTINCT, MongoDB’s $group with $first, and Elasticsearch’s field collapsing.
Stage Category: REDUCE (Removes duplicates)Transformation: N documents → M documents (M ≤ N, duplicates removed)
When to Use
When NOT to Use
Parameters
Deduplication Strategies
Configuration Examples
For best results, place deduplicate after sorting/reranking so that keep: "first" retains the highest-scored duplicate. This ensures you keep the most relevant version of each document.
Common Pipeline Patterns
Web Search Deduplication
Cross-Collection Dedup
Error Handling
- Group By - Group documents with aggregation
- Limit - Truncate results after deduplication
- Sample - Random sampling (different from dedup)
- Unwind - Inverse: expand grouped items