Atlas Search index behaviour with $out versus $merge targets
Parent: Read Offload via Caching and Precomputed Views ($merge/$out, Computed Pattern) · Published reference · snapshot 2026-10-31
↓ Facts as markdownall context files
Source-anchored research for Atlas Search index behaviour with $out versus $merge targets. Run status: COMPLETED.
These notes link each claim to its source. Some citations identify archived research reports that are no longer hosted on this site. A published reference means the content is available; it does not certify independent review or accuracy.Read the editorial policy and follow the sources before relying on a claim.
Definitions
- The ordinary-index copying described for $out is not a guarantee that Search indexes survive: $out creates a temporary collection, copies index definitions, populates it, and renames it with dropTarget:true, while the Search FAQ explicitly says Search indexes are not copied to destination collections. (medium confidence) [source]
Problems, failure modes and limitations
- $out atomically replaces the existing collection at completion, while writes already completed by $merge are not rolled back if a later document causes an error; retaining the target collection therefore does not provide an atomic full-refresh guarantee. (medium confidence) [source]
Comparisons and alternatives
- For a Search-indexed precomputed target, using $merge to incorporate results into the existing collection follows MongoDB’s documented alternative to $out. Percona independently demonstrates that $merge can update or replace individual documents rather than replacing the whole target collection; its example does not test Atlas Search. (medium confidence) [source]
Facts and statements
- MongoDB documents that using $out to modify a target with an existing Search index requires deleting and recreating that Search index; it recommends considering $merge instead. (medium confidence) (verified as of 2026-10-14) [source]
- Setting $merge.whenMatched to "replace" replaces documents matched by the on fields; it does not make the target a complete replacement snapshot. Existing target documents with no corresponding aggregation result remain, so a switch from $out needs an explicit policy for those documents. (medium confidence) [source]
- In a September 2020 firsthand report, a user observed old Search-index contents after refreshing the target with $out. A responder attributed the detachment to the replacement collection’s changed UUID, and the user reported that switching to $merge resolved the problem. This is historical incident evidence, not a test of every modern release. (low confidence) [source]
- The 2020 user’s description of $merge updating Search immediately is an anecdote, not a visibility guarantee: MongoDB documents Search indexes as eventually consistent and warns that collection changes may not immediately be available to Search queries. (medium confidence) [source]
- $out replaces an existing output collection completely, whereas $merge can insert, merge, or replace individual documents in the existing target; these are different refresh semantics for a searchable precomputed collection. (medium confidence) [source]
- $merge requires a unique index whose keys correspond to the on identifier fields and whose collation matches the aggregation. A design that only provisions an Atlas Search index must also satisfy this separate unique-index requirement. (low confidence) [source]
Children
- No children recorded.