<!-- llms-explorer concept facts · https://llms-explorer.com/tree/atlas-search-index-behaviour-with-out-versus-merge-targets/ · pack 2026-10-31 · ~1016 tokens -->

# Atlas Search index behaviour with $out versus $merge targets

> Source-anchored research for Atlas Search index behaviour with $out versus $merge targets. Run status: COMPLETED.

Parent: [Read Offload via Caching and Precomputed Views ($merge/$out, Computed Pattern)](https://llms-explorer.com/tree/read-offload-via-caching-and-precomputed-views-merge-out-computed-pattern/) · 4 facets · 9 facts · page: https://llms-explorer.com/tree/atlas-search-index-behaviour-with-out-versus-merge-targets/

## 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](https://www.mongodb.com/docs/manual/reference/operator/aggregation/out.md)

## 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](https://www.mongodb.com/docs/manual/reference/operator/aggregation/out.md)

## 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](https://www.mongodb.com/docs/manual/reference/operator/aggregation/out.md)

## 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](https://www.mongodb.com/docs/manual/reference/operator/aggregation/out.md)
- 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](https://www.mongodb.com/docs/manual/reference/operator/aggregation/merge.md)
- 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](https://www.mongodb.com/community/forums/t/index-search-not-updated-aggregate-out/8901)
- 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](https://www.mongodb.com/community/forums/t/index-search-not-updated-aggregate-out/8901)
- $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](https://www.mongodb.com/docs/manual/reference/operator/aggregation/out.md)
- $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](https://www.mongodb.com/docs/manual/reference/operator/aggregation/merge.md)
